Skip to content
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
24 changes: 12 additions & 12 deletions src/datatype.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,18 @@ void jl_compute_field_offsets(jl_datatype_t *st)
// based on whether its definition is self-referential
if (w->types != NULL) {
st->isbitstype = st->isinlinealloc = st->isconcretetype && !st->mutabl;
if (st->isinlinealloc) {
size_t i, nf = jl_svec_len(w->types);
for (i = 0; i < nf; i++) {
jl_value_t *fld = jl_svecref(w->types, i);
if (references_name(fld, w->name)) {
st->isinlinealloc = 0;
st->isbitstype = 0;
st->zeroinit = 1;
break;
}
}
}
size_t i, nf = jl_svec_len(st->types);
for (i = 0; i < nf; i++) {
jl_value_t *fld = jl_svecref(st->types, i);
Expand All @@ -327,18 +339,6 @@ void jl_compute_field_offsets(jl_datatype_t *st)
st->has_concrete_subtype &= !jl_is_datatype(fld) || ((jl_datatype_t *)fld)->has_concrete_subtype;
}
}
if (st->isinlinealloc) {
size_t i, nf = jl_svec_len(w->types);
for (i = 0; i < nf; i++) {
jl_value_t *fld = jl_svecref(w->types, i);
if (references_name(fld, w->name)) {
st->isinlinealloc = 0;
st->isbitstype = 0;
st->zeroinit = 1;
break;
}
}
}
}
// If layout doesn't depend on type parameters, it's stored in st->name->wrapper
// and reused by all subtypes.
Expand Down
8 changes: 8 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5924,6 +5924,14 @@ let x = UnionFieldInlineStruct(1, 3.14)
@test CInlineUnion[end] == x
end

# issue 33709
struct A33709
a::Union{Nothing,A33709}
end
let a33709 = A33709(A33709(nothing))
@test isnothing(a33709.a.a)
end

# issue 31583
a31583 = "a"
f31583() = a31583 === "a"
Expand Down