Julia: Array allocation with negative size should throw a `ArgumentError` not a `ErrorException`

Created on 12 Jun 2019  ·  6Comments  ·  Source: JuliaLang/julia

julia> try 
       fill('a', -10)
       catch err
       @show typeof(err)
       end

typeof(err) = ErrorException
bug good first issue help wanted

Most helpful comment

I don't think this should be fixed in fill:

julia> Array{Int,2}(undef, -1, -4)
ERROR: invalid Array dimensions
Stacktrace:
 [1] Array{Int64,2}(::UndefInitializer, ::Int64, ::Int64) at ./boot.jl:404
 [2] top-level scope at none:0

Fixing it in fill would only fix one of all the functions that use array allocations.

All 6 comments

Can I be assigned this?

There's no way to assign issues to people outside of the org. Just go ahead and make a PR to fix it 👍

I can't find where to change. I checked julia/base/array.jl . Isn't fill a numpy method? I don't understand where to make changes,Please help.

Do @which fill(-1, -1) from the REPL.
Which will tell you where it is defined.

Isn't fill a numpy method?

There aren’t any NumPy methods in Julia. Unless you’re using PyCall to call NumPy.

I don't think this should be fixed in fill:

julia> Array{Int,2}(undef, -1, -4)
ERROR: invalid Array dimensions
Stacktrace:
 [1] Array{Int64,2}(::UndefInitializer, ::Int64, ::Int64) at ./boot.jl:404
 [2] top-level scope at none:0

Fixing it in fill would only fix one of all the functions that use array allocations.

Was this page helpful?
0 / 5 - 0 ratings