-
Notifications
You must be signed in to change notification settings - Fork 382
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
if-expression requires parentheses within string interpolation #1767
Comments
I printed the token for examples:
seems that all strings are identified as multiline strings. |
that's incorrect but that shouldn't cause the problem that we see here, mhhhh |
@andylokandy I quickly tried adding |
I think I've figured it out. An |
@andrevidela that's amazing! Anyway I'll investigate the weird multiline string a bit. |
The `if then else` syntax expects a block for the `then` and `else` parts. Before this patch, the token `InterpEnd` was not a valid follow up token to end a block. This adds `InterpEnd` as a closing token for blocks, allowing `if then else` in interpolation slices without additional parens.
I've figured it out! It was a silly printing problem, the flag indicating whether the string is multiline is showed in the opposite: Idris2/src/Parser/Lexer/Source.idr Lines 58 to 59 in 34167d5
Idris2/src/Parser/Lexer/Source.idr Lines 87 to 88 in 34167d5
|
Those booleans are evil… |
When using an
if
-expression within string interpolation an error gets reported. But the error mentions that the token 'if' belongs to the expected tokens.Steps to Reproduce
Evaluate the following string:
"\{ if True then "a" else "b" }"
Expected Behavior
I would expect that it evaluates to
"a"
or a parse error that says that
if
is not allowed in this position.Observed Behavior
It works as expected when the
if
-expression is surrounded with parentheses.Idris2 Version
Version 0.4.0-5f3480120
The text was updated successfully, but these errors were encountered: