-
Notifications
You must be signed in to change notification settings - Fork 323
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
Broken redefinition of variable inside if-then expression #6211
Comments
Looks like the situation is more complex. Looking for help by language and parser experts, CCing @wdanilo and @kazcw. Following program offers "block" and "one liner" version of the same code: block =
a = 5
if a == 3 then a = 10 else
a = 15
a # needn't be here, still OK without this line
line =
a = 5
if a == 3 then a = 10 else a = 15 Running Of course using How shall the engine behave? Should the "one liner" behave just like the "block" (without |
Wojciech wrote:
I will modify the code so the "one liner" behaves the same as the block version. |
The OprApp[" ", "a = 15", Ident["", "a", Ident["", "a", false, 0, false, false]],
Either{right=Operator[" ", "=", ]}, Number[" ", "15", null, Digits["", "15", null], null]] in case of the "block" version it is: Assignment[" ", "a = 15", Ident["", "a", Ident["", "a", false, 0, false, false]],
Operator[" ", "=", ], Number[" ", "15", null, Digits["", "15", null], null]] I believe the right fix is to modify the Rust parser to treat even the "oneliner" as an |
Jaroslav Tulach reports a new STANDUP for yesterday (2023-05-12): Progress: -
Next Day: Finding a way to join Dmitry's #6655 and my #6584
|
Inside then branch of an if expression, a variable assignment is syntactically correct. The following snippet should create a new variable named
a
inside the then expression, and returnNothing
.But it fails with
The text was updated successfully, but these errors were encountered: