Yuescript icon indicating copy to clipboard operation
Yuescript copied to clipboard

Incorrect syntax error when asserts have a message and a space after the call

Open ChildishGiant opened this issue 3 years ago • 2 comments

If an assert has a message after it and a space between the call and the brackets it will throw a syntax error.

assert (1==1, "Oopsies!")

1: syntax error
assert (1==1, "Oopsies!")
            ^

These both run fine: assert(1==1, "Oopsies!") assert (1==1)

ChildishGiant avatar Apr 14 '22 18:04 ChildishGiant

This is an intended behavior. Function call should be written as function name followed by whitespace then the arguments separated by commas, or function name followed by parentheses without any whitespace. So that assert (1==1) is actually seen as assert((1==1)), and assert (1==1, "Oopsies!") as assert((1==1, "Oopsies!")) is invalid code.

pigpigyyy avatar Apr 15 '22 15:04 pigpigyyy

Maybe a more detailed error, surely the space is the issue here, not the comma?

ChildishGiant avatar Apr 16 '22 18:04 ChildishGiant

The compiler should now give the detailed error by newest commit.

1: write invoke arguments in parentheses without leading spaces or leading spaces without parentheses
assert (1==1, "Oopsies!")
       ^

pigpigyyy avatar Nov 08 '22 02:11 pigpigyyy