-
-
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
don't mutate lhs while destructuring #40737
Conversation
Triage thinks this is the right thing to do. |
4d07e2f
to
bcccabf
Compare
Discovered while working on #40737. Currently, this throws an unintuitive error: ```julia julia> a, f()... = 1, 2, 3 ERROR: syntax: ssavalue with no def Stacktrace: [1] top-level scope @ REPL[1]:1 ``` Might as well fix this properly - Why not allow function definitions to slurp a little from time to time? ;)
@nanosoldier |
Your package evaluation job has completed - possible new issues were detected. A full report can be found here. cc @maleadt |
@nanosoldier |
Your package evaluation job has completed - possible new issues were detected. A full report can be found here. cc @maleadt |
This does seem strictly better. I'm pretty sure we can sweep any breakage under the rug of undefined behavior. |
dbe795d
to
560dcc7
Compare
Jeff was a bit sceptical about this in #40574, but I think this is worth doing since it seems strictly more useful than the current behavior and we already go out of our way in cases like `x, y = y, x` to only assign to the lhs after the rhs has been evaluated, so I think handling `x[2], x[1] = x` in a similar way would only be consistent. As a general rule that assignment will always happen after destructuring does not seem much less obvious than the current behavior to me. This might technically be slightly breaking, but I would be surprised if people relied on the current behavior here. Nevertheless, it would probably be good to run PkgEval if we decide to go with this change. closes #40574
560dcc7
to
030bf53
Compare
Jeff was a bit sceptical about this in JuliaLang#40574, but I think this is worth doing since it seems strictly more useful than the current behavior and we already go out of our way in cases like `x, y = y, x` to only assign to the lhs after the rhs has been evaluated, so I think handling `x[2], x[1] = x` in a similar way would only be consistent. As a general rule that assignment will always happen after destructuring does not seem much less obvious than the current behavior to me. This might technically be slightly breaking, but I would be surprised if people relied on the current behavior here. Nevertheless, it would probably be good to run PkgEval if we decide to go with this change. closes JuliaLang#40574
Discovered while working on #40737. Currently, this throws an unintuitive error: ```julia julia> a, f()... = 1, 2, 3 ERROR: syntax: ssavalue with no def Stacktrace: [1] top-level scope @ REPL[1]:1 ``` Might as well fix this properly - Why not allow function definitions to slurp a little from time to time? ;)
Jeff was a bit sceptical about this in JuliaLang#40574, but I think this is worth doing since it seems strictly more useful than the current behavior and we already go out of our way in cases like `x, y = y, x` to only assign to the lhs after the rhs has been evaluated, so I think handling `x[2], x[1] = x` in a similar way would only be consistent. As a general rule that assignment will always happen after destructuring does not seem much less obvious than the current behavior to me. This might technically be slightly breaking, but I would be surprised if people relied on the current behavior here. Nevertheless, it would probably be good to run PkgEval if we decide to go with this change. closes JuliaLang#40574
Discovered while working on JuliaLang#40737. Currently, this throws an unintuitive error: ```julia julia> a, f()... = 1, 2, 3 ERROR: syntax: ssavalue with no def Stacktrace: [1] top-level scope @ REPL[1]:1 ``` Might as well fix this properly - Why not allow function definitions to slurp a little from time to time? ;)
Discovered while working on #40737. Currently, this throws an unintuitive error: ```julia julia> a, f()... = 1, 2, 3 ERROR: syntax: ssavalue with no def Stacktrace: [1] top-level scope @ REPL[1]:1 ``` Might as well fix this properly - Why not allow function definitions to slurp a little from time to time? ;) (cherry picked from commit 5c49a0d)
@JeffBezanson was a bit sceptical about this in #40574, but I think this
is worth doing since it seems strictly more useful than the current
behavior and we already go out of our way in cases like
x, y = y, x
toonly assign to the lhs after the rhs has been evaluated, so I think
handling
x[2], x[1] = x
in a similar way would only be consisten. As ageneral rule that assignment will always happen after destructuring does
not seem much less obvious than the current behavior to me. This might
technically be slightly breaking, but I would be surprised if people
relied on the current behavior here. Nevertheless, it would probably
good to run PkgEval if we decide to go with this change.
closes #40574