How to desctructure a namedtuple and declare the variables to be constants using the new destructuring syntax?

julia> const nt = (; a = 1)
(a = 1,)

julia> const a_ = nt.a

This defines a_ as a constant. Now julia v1.7 has introduced the new destructuring syntax

julia> (; a) = nt
(a = 1,)

Is there any way to use this syntax and declare a to be a constant as well? Something like this doesn’t work:

julia> (; const a) = nt
ERROR: syntax: expected assignment after "const"

This seems to work:

julia> nt = (; a = "hi")
(a = "hi",)

julia> (const a; (; a) = nt)
(a = "hi",)

julia> a = "bye"
WARNING: redefinition of constant a. This may fail, cause incorrect answers, or produce other errors.

Kind of strange though.


julia> begin
           const a
           (; a) = nt
(a = "hi",)

works too, and might be a bit more clear.