Skip to content

Commit b3a99c0

Browse files
authored
fix #41654, layout of 0-field structs with circular supertypes (#41660)
1 parent 69f8bce commit b3a99c0

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/builtins.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,9 +1557,9 @@ JL_CALLABLE(jl_f__typebody)
15571557
// able to compute the layout of the object before needing to
15581558
// publish it, so we must assume it cannot be inlined, if that
15591559
// check passes, then we also still need to check the fields too.
1560-
if (!dt->name->mutabl && !references_name((jl_value_t*)dt->super, dt->name, 1)) {
1560+
if (!dt->name->mutabl && (nf == 0 || !references_name((jl_value_t*)dt->super, dt->name, 1))) {
15611561
int mayinlinealloc = 1;
1562-
size_t i, nf = jl_svec_len(ft);
1562+
size_t i;
15631563
for (i = 0; i < nf; i++) {
15641564
jl_value_t *fld = jl_svecref(ft, i);
15651565
if (references_name(fld, dt->name, 1)) {

test/core.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7236,6 +7236,12 @@ end
72367236
@test string((B40050(),)) == "($B40050(),)"
72377237
@test_broken isbitstype(Tuple{B40050})
72387238

7239+
# issue #41654
7240+
struct X41654 <: Ref{X41654}
7241+
end
7242+
@test isbitstype(X41654)
7243+
@test ('a'=>X41654(),)[1][2] isa X41654
7244+
72397245
# Issue #34206/34207
72407246
function mre34206(a, n)
72417247
va = view(a, :)

0 commit comments

Comments
 (0)