Skip to content

Conversation

joente
Copy link
Member

@joente joente commented Jan 5, 2022

Be more forgiving for missing semicolon at the end-of-a-statement. Especially after a "block" it is not obvious that a semicolon is required to end the statement.

For example:

for (x in range(10)) {
  // do something
}

return x;

The code above used to return with an error as a semicolon is missing after the for..in statement. This pull request solves this by being more forgiving.

Warning: With this change, a code block should no longer accept a direct followup as for example indexing or applying functions.

For example:

{
  range(10);
}.len(); 

The code above used to return 10 as this is the length of range 10 in the code block above. The new syntax would return the length of the collection, as it sees .len(); as a new statement.

To get the 10 like before, we now have to wrap the code in parenthesis, like this:

({
  range(10);
}).len(); 

The same is true for not (!) or sign (+/-) conversions, thus:

!!{
  true;
}; 

will raise an error (It will try to parse the code block as a thing...). As a fix, the code block can be wrapped in parenthesis.

!!({
  true;
}); 

@joente joente self-assigned this Jan 5, 2022
@joente joente merged commit 933bf88 into main Jan 5, 2022
@joente joente deleted the syntax branch February 7, 2022 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant