Skip to content

Commit 8208f86

Browse files
committed
Increase union stack size
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.
1 parent d91a719 commit 8208f86

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

src/subtype.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ extern "C" {
3939
// Union type decision points are discovered while the algorithm works.
4040
// If a new Union decision is encountered, the `more` flag is set to tell
4141
// the forall/exists loop to grow the stack.
42+
// TODO: the stack probably needs to be artifically large because of some
43+
// deeper problem (see #21191) and could be shrunk once that is fixed
4244
typedef struct {
4345
int depth;
4446
int more;
45-
uint32_t stack[10]; // stack of bits represented as a bit vector
47+
uint32_t stack[100]; // stack of bits represented as a bit vector
4648
} jl_unionstate_t;
4749

4850
// Linked list storing the type variable environment. A new jl_varbinding_t

test/inference.jl

+1-2
Original file line numberDiff line numberDiff line change
@@ -657,8 +657,7 @@ let A = 1:2, z = zip(A, A, A, A, A, A, A, A, A, A, A, A)
657657
end
658658
# introduce TypeVars in Unions in invariant position
659659
let T = Val{Val{Val{Union{Int8,Int16,Int32,Int64,UInt8,UInt16,UInt32,UInt64}}}}
660-
#TODO: this test hits an assertion (see #21191)
661-
#@test T <: Core.Inference.limit_type_depth(T, 0)
660+
@test T <: Core.Inference.limit_type_depth(T, 0)
662661
end
663662

664663
# issue #20704

test/subtype.jl

+20
Original file line numberDiff line numberDiff line change
@@ -1070,3 +1070,23 @@ end
10701070
@testintersect(Tuple{A20992{R, D, d} where d where D, Int} where R,
10711071
Tuple{C20992{S, n, T, D, d} where d where D where T where n where S, Any},
10721072
Tuple{C20992, Int})
1073+
1074+
# issue #21191
1075+
let T1 = Val{Val{Val{Union{Int8,Int16,Int32,Int64,UInt8,UInt16}}}},
1076+
T2 = Val{Val{Val{Union{Int8,Int16,Int32,Int64,UInt8, S}}}} where S
1077+
@test T1 <: T2
1078+
end
1079+
1080+
# comment in issue #20103
1081+
let ints = (Int, Int32, UInt, UInt32)
1082+
const Ints = Union{ints...}
1083+
vecs = []
1084+
for i = 2:4, t in ints
1085+
push!(vecs, NTuple{i, t})
1086+
end
1087+
const Vecs = Union{vecs...}
1088+
T = Type{Tuple{V, I}} where V <: Vecs where I <: Ints
1089+
@testintersect(T, T, T)
1090+
test{V <: Vecs, I <: Ints}(a::Type{Tuple{V, I}}) = I
1091+
test{V <: Vecs, I <: Ints}(a::Type{Tuple{V, I}}) = I
1092+
end

0 commit comments

Comments
 (0)