Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #28673, error for trying to allocate e.g. Array{3} #30281

Merged
merged 1 commit into from
Dec 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix #28673, error for trying to allocate e.g. Array{3}
  • Loading branch information
JeffBezanson committed Dec 5, 2018
commit 181f8db9afb042163c3e913d5eb9fe5da45e2586
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