-
-
Notifications
You must be signed in to change notification settings - Fork 150
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
[YSH] setglobal d.key mutates local instead of global #1841
Comments
[Results moved into description.] |
What tests do you think are undesired behavior here? The first piece of code looks wrong
Because The rule should be simple: inside a proc, use This code seems to be violating that simple rule |
The code is using the setglobal keyword to set the global. However, it (wrongly) does not do so if there is a local variable defined that happens to have the same name (global is shadowed), instead of just (correctly) setting the global. I think the fact that the example does not produces a failure even means that |
A |
The local is being mutated, not the global. Issue #1841
setglobal
OK thank you, that's a pretty serious oversight I added a failing test case here - 7cd9edb And I can see in the code where it's ignoring This bug report was hard to understand. I think it will help to use this format:
The output of the tests looks like this:
You're definitely welcome to add such tests The other 2 issues you mention aren't clear either, though I suspect the core issue is that we don't do any dynamic checks differently at the top level vs. inside a proc. There are different static checks though The doc for this is But I haven't touched it in a couple years, so there are probably some things missing Luckily this |
I'll try to show how I attempted to make this issue and the other short and telling.
Hm, I first hadn't grasped yet that set global it's actually setting a local. I just found that it's not setting the global in my code (but don't just want to say "it doesn't work"). I mostly don't know what is actually wrong at first, and it could be multiple and different things that cause the more complex application test to fail.
Hm, I tried YSH's Here is what it's telling:
|
It skips locals that shadow globals. This is issue #1841.
Initial results of the tests:
Tests:
The text was updated successfully, but these errors were encountered: