Open
Description
A syntax.jl test documents:
# `const` assignment to `_` drops the assignment effect,
# and the conversion, but not the rhs.
julia> _::Int = 1
1
julia> _::String = "a"
ERROR: cannot set type for global Main._. It already has a value or is already set to a different type.
Stacktrace:
[1] top-level scope
@ REPL[2]:1
On both 1.11 and nightly, a set_binding_type!
or globaldecl
, respectively, sneaks through.
1.11:
julia> Meta.@lower _::Int = 1
:($(Expr(:thunk, CodeInfo(
@ none within `top-level scope`
1 ─ global Main._
│ %2 = Int
│ Core.set_binding_type!(Main, :_, %2)
└── return 1
))))
Nightly:
julia> Meta.@lower _::Int = 1
:($(Expr(:thunk, CodeInfo(
1 ─ %1 = Main.Int
│ $(Expr(:globaldecl, :(Main._), :(%1)))
│ $(Expr(:latestworld))
└── return 1
))))