Skip to content

Wrapping NamedTuple in struct is no longer bitstype in 1.7 #43411

Closed
@cortner

Description

@cortner

cf brief discussion on discourse

This bug(?) occurs on 1.7 but not on 1.6:

struct Wrapper{SYMS, TT}
   x::NamedTuple{SYMS, TT}
end
randnt() = Wrapper((a = randn(), b = rand(), c = rand(1:5), d = randn(SVector{3, Float64})))
X = randnt()
@allocated randnt()  # 64
isbits(X)   # false
isbits(X.x)   # true 

But if the wrapper is defined differently then the isbits == true is recovered:

struct Wrapper1{NT} 
   x::NT
end
randnt1() = Wrapper1((a = randn(), b = rand(), c = rand(1:5), d = randn(SVector{3, Float64})))
X1 = randnt1()
@allocated randnt1() # 0 
isbits(X1) # true
isbits(X1.x) # true

Because of this, it is easy enough to produce a work-around, but it feels like that shouldn't be necessary and the behaviour described above should not occur?

julia> versioninfo()
Julia Version 1.7.0
Commit 3bf9d17731 (2021-11-30 12:12 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin21.1.0)
  CPU: Apple M1 Max
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, cyclone)

(built from source)

Metadata

Metadata

Assignees

Labels

regressionRegression in behavior compared to a previous version

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions