From 5abbbcde9b9a31fbe083bb49b22ee44e5363426b Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Tue, 20 Jul 2021 17:56:00 -0400 Subject: [PATCH] fix #41654, layout of 0-field structs with circular supertypes --- src/builtins.c | 4 ++-- test/core.jl | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/builtins.c b/src/builtins.c index 4ef5d5ac5c2df..b186aadbed5d2 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -1557,9 +1557,9 @@ JL_CALLABLE(jl_f__typebody) // able to compute the layout of the object before needing to // publish it, so we must assume it cannot be inlined, if that // check passes, then we also still need to check the fields too. - if (!dt->name->mutabl && !references_name((jl_value_t*)dt->super, dt->name, 1)) { + if (!dt->name->mutabl && (nf == 0 || !references_name((jl_value_t*)dt->super, dt->name, 1))) { int mayinlinealloc = 1; - size_t i, nf = jl_svec_len(ft); + size_t i; for (i = 0; i < nf; i++) { jl_value_t *fld = jl_svecref(ft, i); if (references_name(fld, dt->name, 1)) { diff --git a/test/core.jl b/test/core.jl index 0a92c3e1aeef3..a9c9f6222cd9f 100644 --- a/test/core.jl +++ b/test/core.jl @@ -7236,6 +7236,12 @@ end @test string((B40050(),)) == "($B40050(),)" @test_broken isbitstype(Tuple{B40050}) +# issue #41654 +struct X41654 <: Ref{X41654} +end +@test isbitstype(X41654) +@test ('a'=>X41654(),)[1][2] isa X41654 + # Issue #34206/34207 function mre34206(a, n) va = view(a, :)