Open
Description
opened on Jun 10, 2024
In the lowering source code, we have a comment that says
;; local x, y=2, z => local x;local y;local z;y = 2
but these days, without parentheses that's actually
local (x, y)=(2, z)
i.e. a destructuring assignment to x
and y
.
However, even with parentheses, I'm not sure the behavior is actually what you want:
julia> global (a::Float64=1), (b::Int64=2.0), c
2.0
This returns the right-most assignment, but that seems like a bit of an arbitrary return value.
I would strongly suggest that we make that syntax case (which is unreachable without parentheses anyway) an error and only permit a single syntactic assignment per statement.
I will also note that the original code that added this behavior wanted it "for consistency with let", but let parses different these days:
julia> let a,b=2
(a,b)
end
ERROR: UndefVarError: `a` not defined in local scope
Suggestion: check for an assignment to a local variable that shadows a global of the same name.
Stacktrace:
[1] top-level scope
@ REPL[8]:2
julia> let;
local a,b=2
(a, b)
end
ERROR: BoundsError: attempt to access Int64 at index [2]
Stacktrace:
[1] indexed_iterate(I::Int64, i::Int64, state::Nothing)
@ Base ./tuple.jl:169
[2] top-level scope
@ REPL[12]:2
Activity