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 12, 2017
1 parent d91a719 commit 8208f86
Show file tree
Hide file tree
Showing 3 changed files with 24 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
20 changes: 20 additions & 0 deletions test/subtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1070,3 +1070,23 @@ end
@testintersect(Tuple{A20992{R, D, d} where d where D, Int} where R,
Tuple{C20992{S, n, T, D, d} where d where D where T where n where S, Any},
Tuple{C20992, Int})

# 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

# comment in issue #20103
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

0 comments on commit 8208f86

Please sign in to comment.