Open Akirathan opened 1 year ago
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 block
is fine. Running line
generates an error as described in the issue description.
Of course using a = 10
in the "one liner" makes little sense. However using a = 10
in the block (without a
being used further) makes little sense as well.
How shall the engine behave? Should the "one liner" behave just like the "block" (without a
being returned)? Thank you in advance for your advises.
Wojciech wrote:
these 2 codes should behave the same way
I will modify the code so the "one liner" behaves the same as the block version.
The Tree
we get from the Rust parser is causing the difference. While in the case of "oneliner" it is:
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 Assignment
. Passing to @kazcw
Jaroslav Tulach reports a new STANDUP for yesterday (2023-05-12):
Progress: - TypeNameTest
and RuntimeErrorsTest
: https://github.com/enso-org/enso/pull/6584/commits/f2df70c70f1e133f3e40914b0306a663d91baa88
Meta
improvements: https://github.com/enso-org/enso/pull/6641#pullrequestreview-1424326671./run gui watch
with local project-manager
Next Day: Finding a way to join Dmitry's #6655 and my #6584
DiscordDiscord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
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