Skip to content

Commit

Permalink
Increase union stack size
Browse files Browse the repository at this point in the history
This solves #21191 and similar issues, but there probably is an
underlying problem yet to be solved which makes such a large stack
necessary in the first place.
  • Loading branch information
martinholters committed Apr 17, 2017
1 parent 934e0e3 commit bdc1243
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/subtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ extern "C" {
// Union type decision points are discovered while the algorithm works.
// If a new Union decision is encountered, the `more` flag is set to tell
// the forall/exists loop to grow the stack.
// TODO: the stack probably needs to be artifically large because of some
// deeper problem (see #21191) and could be shrunk once that is fixed
typedef struct {
int depth;
int more;
uint32_t stack[10]; // stack of bits represented as a bit vector
uint32_t stack[100]; // stack of bits represented as a bit vector
} jl_unionstate_t;

// Linked list storing the type variable environment. A new jl_varbinding_t
Expand Down
3 changes: 1 addition & 2 deletions test/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,7 @@ let A = 1:2, z = zip(A, A, A, A, A, A, A, A, A, A, A, A)
end
# introduce TypeVars in Unions in invariant position
let T = Val{Val{Val{Union{Int8,Int16,Int32,Int64,UInt8,UInt16,UInt32,UInt64}}}}
#TODO: this test hits an assertion (see #21191)
#@test T <: Core.Inference.limit_type_depth(T, 0)
@test T <: Core.Inference.limit_type_depth(T, 0)
end

# issue #20704
Expand Down
18 changes: 18 additions & 0 deletions test/subtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1076,3 +1076,21 @@ struct TT20103{X,Y} end
f20103{X,Y}(::Type{TT20103{X,Y}},x::X,y::Y) = 1
f20103{X}(::Type{TT20103{X,X}},x::X) = 100
@test_broken typeintersect(Type{NTuple{N,E}} where E where N, Type{NTuple{N,E} where N} where E) == Union{} # use @testintersect once fixed
let ints = (Int, Int32, UInt, UInt32)
const Ints = Union{ints...}
vecs = []
for i = 2:4, t in ints
push!(vecs, NTuple{i, t})
end
const Vecs = Union{vecs...}
T = Type{Tuple{V, I}} where V <: Vecs where I <: Ints
@testintersect(T, T, T)
test{V <: Vecs, I <: Ints}(a::Type{Tuple{V, I}}) = I
test{V <: Vecs, I <: Ints}(a::Type{Tuple{V, I}}) = I
end

# issue #21191
let T1 = Val{Val{Val{Union{Int8,Int16,Int32,Int64,UInt8,UInt16}}}},
T2 = Val{Val{Val{Union{Int8,Int16,Int32,Int64,UInt8, S}}}} where S
@test T1 <: T2
end

0 comments on commit bdc1243

Please sign in to comment.