Skip to content

Commit

Permalink
fix #28673, error for trying to allocate e.g. Array{3} (#30281)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored Dec 6, 2018
1 parent 4e97220 commit 1c05d0c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/compiler/tfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@ function array_type_undefable(@nospecialize(a))
return true
else
etype = (a::DataType).parameters[1]
return !(isbitstype(etype) || isbitsunion(etype))
return !(etype isa Type && (isbitstype(etype) || isbitsunion(etype)))
end
end

Expand Down
2 changes: 2 additions & 0 deletions src/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ static inline jl_array_t *_new_array(jl_value_t *atype, uint32_t ndims, size_t *
{
jl_value_t *eltype = jl_tparam0(atype);
size_t elsz = 0, al = 0;
if (!jl_is_kind(jl_typeof(eltype)))
jl_type_error_rt("Array", "element type", (jl_value_t*)jl_type_type, eltype);
int isunboxed = jl_islayout_inline(eltype, &elsz, &al);
int isunion = jl_is_uniontype(eltype);
if (!isunboxed) {
Expand Down
3 changes: 3 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ f47(x::Vector{Vector{T}}) where {T} = 0
@test_throws TypeError TypeVar(:T) <: Any
@test_throws TypeError TypeVar(:T) >: Any

# issue #28673
@test_throws TypeError Array{2}(undef, 1, 2)

# issue #12939
module Issue12939
abstract type Abs; end
Expand Down

0 comments on commit 1c05d0c

Please sign in to comment.