-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviorcompiler:loweringSyntax lowering (compiler front end, 2nd stage)Syntax lowering (compiler front end, 2nd stage)regressionRegression in behavior compared to a previous versionRegression in behavior compared to a previous version
Milestone
Description
In Julia 1.11, using const in front of a variable implied neither local nor global semantics - rather the scope was calculated according to the usual rules:
julia> Meta.@lower function f()
const x = 1
end
:($(Expr(:error, "unsupported `const` declaration on local variable around REPL[1]:2")))
julia> let
const x = 1
end
ERROR: syntax: unsupported `const` declaration on local variable around REPL[2]:2However, in 1.12 dev, as of #54773, it seems that const implicitly implies global:
julia> Meta.@lower function f()
const x = 1
end
:($(Expr(:error, "`global const` declaration not allowed inside function around REPL[3]:2")))
julia> let
const x = 1
end
1
julia> x
1This seems like a significant semantic change which I'm not convinced is a good idea. If one wants a global variable within a let block at top level, I think the user should explicitly declare global const x = 1 in the example above.
@Keno is this a bug or was it intentional?
Seelengrab, vchuravy and PallHaraldsson
Metadata
Metadata
Assignees
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviorcompiler:loweringSyntax lowering (compiler front end, 2nd stage)Syntax lowering (compiler front end, 2nd stage)regressionRegression in behavior compared to a previous versionRegression in behavior compared to a previous version