From 8208f86545e07c9581ac21082c8ecfbfb872b8d3 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Wed, 12 Apr 2017 14:25:34 +0200 Subject: [PATCH] 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. --- src/subtype.c | 4 +++- test/inference.jl | 3 +-- test/subtype.jl | 20 ++++++++++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/subtype.c b/src/subtype.c index eeb5d4376f64d..dc5d0afb408a9 100644 --- a/src/subtype.c +++ b/src/subtype.c @@ -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 diff --git a/test/inference.jl b/test/inference.jl index b0673e8e1ba25..0452ecaddc358 100644 --- a/test/inference.jl +++ b/test/inference.jl @@ -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 diff --git a/test/subtype.jl b/test/subtype.jl index 1d9747b5c26bd..f5d13408afd08 100644 --- a/test/subtype.jl +++ b/test/subtype.jl @@ -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