-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@inbounds
overrides val
variable in macros. Wrong usage of local
#54417
Comments
This sounds like a bug nearly identical to #53667, but yeah we could rename that to something more awkward to avoid clashes while this bug is still pending in the hygiene computation |
Linking #48910 which has a similar cause/problem (although with |
I'm confused by the behavior of julia> begin
x = 2
begin
local x = 3
end
x
end
3
julia> x = 2
begin
local x = 3
end
x
2 # works correctly in global scope?
julia> begin
x = 2
if x > 1
local x = 3
end
x
end
3
julia> begin
x = 2
for i in 1:x
local x = 3
end
x
end
2 I'm referring to the manual page on scoping https://docs.julialang.org/en/v1/manual/variables-and-scoping/
If |
@inbounds
overrides val
variable in macros @inbounds
overrides val
variable in macros. Wrong usage of local
It took me a while when debugging a compiled pattern symbolics matcher to realize why pattern variables i've named
val
were overridden by other values. I've ended up adding a prefix to those symbols to avoid the issue. The macro shouldn't beesc
aped, as fresh symbols are needed to avoid clashes.The reason is because
My intuition was always that nested macro calls that "access" the same symbol, should hygiene the symbol in the innermost macro expansion, but it seems it's not the case. What's the correct pattern of macro hygiene for these cases? shall I file a PR renaming that
val
in@inbounds
to something less likely to clash with outer identifiers?Installed via juliaup
The text was updated successfully, but these errors were encountered: