Skip to content

Commit 89d850e

Browse files
vtjnashstaticfloat
authored andcommitted
fix missing field type initialization vars (#44797)
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)
1 parent 8477926 commit 89d850e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/jltypes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,7 +1806,7 @@ void jl_reinstantiate_inner_types(jl_datatype_t *t) // can throw!
18061806
for (i = 0; i < n; i++)
18071807
env[i].val = jl_svecref(ndt->parameters, i);
18081808

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

@@ -1816,7 +1816,7 @@ void jl_reinstantiate_inner_types(jl_datatype_t *t) // can throw!
18161816
for (i = 0; i < n; i++)
18171817
env[i].val = jl_svecref(ndt->parameters, i);
18181818
assert(ndt->types == NULL);
1819-
ndt->types = inst_ftypes(t->types, env, &top);
1819+
ndt->types = inst_ftypes(t->types, &env[n - 1], &top);
18201820
jl_gc_wb(ndt, ndt->types);
18211821
if (ndt->isconcretetype) { // cacheable
18221822
jl_compute_field_offsets(ndt);

test/core.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,15 @@ end
239239
#struct S22624{A,B,C} <: Ref{S22624{Int64,A}}; end
240240
@test_broken @isdefined S22624
241241

242+
# issue #42297
243+
mutable struct Node42297{T, V}
244+
value::V
245+
next::Union{Node42297{T, T}, Node42297{T, Val{T}}, Nothing}
246+
Node42297{T}(value) where {T} = new{T, typeof(value)}(value, nothing)
247+
end
248+
@test fieldtype(Node42297{Int,Val{Int}}, 1) === Val{Int}
249+
@test fieldtype(Node42297{Int,Int}, 1) === Int
250+
242251
# issue #3890
243252
mutable struct A3890{T1}
244253
x::Matrix{Complex{T1}}

0 commit comments

Comments
 (0)