Skip to content

Commit

Permalink
fix missing field type initialization vars (#44797)
Browse files Browse the repository at this point in the history
We were accidentally passing the start of the list instead of the end of
the list, resulting in some values passing through uninitialized.

Fix #42297 regression

(cherry picked from commit 5f2abf6)
  • Loading branch information
vtjnash authored and staticfloat committed Dec 22, 2022
1 parent 8477926 commit 89d850e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1806,7 +1806,7 @@ void jl_reinstantiate_inner_types(jl_datatype_t *t) // can throw!
for (i = 0; i < n; i++)
env[i].val = jl_svecref(ndt->parameters, i);

ndt->super = (jl_datatype_t*)inst_type_w_((jl_value_t*)t->super, env, &top, 1);
ndt->super = (jl_datatype_t*)inst_type_w_((jl_value_t*)t->super, &env[n - 1], &top, 1);
jl_gc_wb(ndt, ndt->super);
}

Expand All @@ -1816,7 +1816,7 @@ void jl_reinstantiate_inner_types(jl_datatype_t *t) // can throw!
for (i = 0; i < n; i++)
env[i].val = jl_svecref(ndt->parameters, i);
assert(ndt->types == NULL);
ndt->types = inst_ftypes(t->types, env, &top);
ndt->types = inst_ftypes(t->types, &env[n - 1], &top);
jl_gc_wb(ndt, ndt->types);
if (ndt->isconcretetype) { // cacheable
jl_compute_field_offsets(ndt);
Expand Down
9 changes: 9 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,15 @@ end
#struct S22624{A,B,C} <: Ref{S22624{Int64,A}}; end
@test_broken @isdefined S22624

# issue #42297
mutable struct Node42297{T, V}
value::V
next::Union{Node42297{T, T}, Node42297{T, Val{T}}, Nothing}
Node42297{T}(value) where {T} = new{T, typeof(value)}(value, nothing)
end
@test fieldtype(Node42297{Int,Val{Int}}, 1) === Val{Int}
@test fieldtype(Node42297{Int,Int}, 1) === Int

# issue #3890
mutable struct A3890{T1}
x::Matrix{Complex{T1}}
Expand Down

0 comments on commit 89d850e

Please sign in to comment.