Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle unbound vars in NTuple fields #55405

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -2084,6 +2084,12 @@ static int references_name(jl_value_t *p, jl_typename_t *name, int affects_layou
return references_name(((jl_uniontype_t*)p)->a, name, affects_layout, freevars) ||
references_name(((jl_uniontype_t*)p)->b, name, affects_layout, freevars);
}
if (jl_is_vararg(p)) {
jl_value_t *T = ((jl_vararg_t*)p)->T;
jl_value_t *N = ((jl_vararg_t*)p)->N;
return (T && references_name(T, name, affects_layout, freevars)) ||
(N && references_name(N, name, affects_layout, freevars));
}
if (jl_is_typevar(p))
return 0; // already checked by unionall, if applicable
if (jl_is_datatype(p)) {
Expand Down
6 changes: 3 additions & 3 deletions src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1961,7 +1961,7 @@ static jl_value_t *jl_tupletype_fill(size_t n, jl_value_t *t, int check, int not
t = normalize_unionalls(t);
p = t;
jl_value_t *tw = extract_wrapper(t);
if (tw && t != tw && jl_types_equal(t, tw))
if (tw && t != tw && !jl_has_free_typevars(t) && jl_types_equal(t, tw))
t = tw;
p = t;
check = 0; // remember that checks are already done now
Expand Down Expand Up @@ -2045,7 +2045,7 @@ static jl_value_t *inst_datatype_inner(jl_datatype_t *dt, jl_svec_t *p, jl_value
// normalize types equal to wrappers (prepare for Typeofwrapper)
jl_value_t *tw = extract_wrapper(pi);
if (tw && tw != pi && (tn != jl_type_typename || jl_typeof(pi) == jl_typeof(tw)) &&
jl_types_equal(pi, tw)) {
!jl_has_free_typevars(pi) && jl_types_equal(pi, tw)) {
iparams[i] = tw;
if (p) jl_gc_wb(p, tw);
}
Expand Down Expand Up @@ -2717,7 +2717,7 @@ jl_vararg_t *jl_wrap_vararg(jl_value_t *t, jl_value_t *n, int check, int nothrow
if (valid) {
t = normalize_unionalls(t);
jl_value_t *tw = extract_wrapper(t);
if (tw && t != tw && jl_types_equal(t, tw))
if (tw && t != tw && !jl_has_free_typevars(t) && jl_types_equal(t, tw))
t = tw;
}
}
Expand Down
7 changes: 7 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7495,6 +7495,13 @@ struct A43411{S, T}
end
@test isbitstype(A43411{(:a,), Tuple{Int}})

# issue #55189
struct A55189{N}
children::NTuple{N,A55189{N}}
end
@test fieldtype(A55189{2}, 1) === Tuple{A55189{2}, A55189{2}}
@assert !isbitstype(A55189{2})

# issue #44614
struct T44614_1{T}
m::T
Expand Down