diff --git a/src/jltypes.c b/src/jltypes.c index 4e566339e3014..b2775c6a92de6 100644 --- a/src/jltypes.c +++ b/src/jltypes.c @@ -2495,6 +2495,8 @@ void jl_reinstantiate_inner_types(jl_datatype_t *t) // can throw! for (j = 0; j < jl_array_len(partial); j++) { jl_datatype_t *ndt = (jl_datatype_t*)jl_array_ptr_ref(partial, j); + if (ndt == NULL) + continue; assert(jl_unwrap_unionall(ndt->name->wrapper) == (jl_value_t*)t); for (i = 0; i < n; i++) env[i].val = jl_svecref(ndt->parameters, i); @@ -2506,6 +2508,8 @@ void jl_reinstantiate_inner_types(jl_datatype_t *t) // can throw! if (t->types != jl_emptysvec) { for (j = 0; j < jl_array_len(partial); j++) { jl_datatype_t *ndt = (jl_datatype_t*)jl_array_ptr_ref(partial, j); + if (ndt == NULL) + continue; for (i = 0; i < n; i++) env[i].val = jl_svecref(ndt->parameters, i); assert(ndt->types == NULL); @@ -2514,7 +2518,9 @@ void jl_reinstantiate_inner_types(jl_datatype_t *t) // can throw! if (ndt->isconcretetype) { // cacheable jl_compute_field_offsets(ndt); } + jl_array_ptr_set(partial, j, NULL); } + t->name->partial = NULL; } else { assert(jl_field_names(t) == jl_emptysvec); diff --git a/test/core.jl b/test/core.jl index 446739da33b57..af9a896de59f8 100644 --- a/test/core.jl +++ b/test/core.jl @@ -7551,6 +7551,19 @@ end struct T36104 # check that redefining it works, issue #21816 v::Vector{T36104} end +struct S36104{K,V} + v::S36104{K,V} + S36104{K,V}() where {K,V} = new() + S36104{K,V}(x::S36104) where {K,V} = new(x) +end +@test !isdefined(Base.unwrap_unionall(Base.ImmutableDict).name, :partial) +@test !isdefined(S36104.body.body.name, :partial) +@test hasfield(typeof(S36104.body.body.name), :partial) +struct S36104{K,V} # check that redefining it works + v::S36104{K,V} + S36104{K,V}() where {K,V} = new() + S36104{K,V}(x::S36104) where {K,V} = new(x) +end # with a gensymmed unionall struct Symmetric{T,S<:AbstractMatrix{<:T}} <: AbstractMatrix{T} data::S