Skip to content

Commit

Permalink
fix(compiler): blocks can't start on a newline (#4182)
Browse files Browse the repository at this point in the history
Fixes #3985

For the record, I do not officially endorse

```
if stuff
{

}
```

but I guess it should be allowed to parse correctly :)

*By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
  • Loading branch information
MarkMcCulloh authored Sep 14, 2023
1 parent eb9f00f commit 7bedd9a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 0 additions & 2 deletions libs/tree-sitter-wing/src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ static bool scan_automatic_block(TSLexer *lexer)
return false;
if (lexer->is_at_included_range_start(lexer))
return true;
if (lexer->lookahead == '\n')
break;
if (!iswspace(lexer->lookahead))
return false;
skip(lexer);
Expand Down
16 changes: 16 additions & 0 deletions libs/tree-sitter-wing/test/corpus/statements/statements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,22 @@ if false {}

--------------------------------------------------------------------------------

(source
(if_statement
condition: (bool)
block: (block)))

================================================================================
If Newline Block
================================================================================

if false
{

}

--------------------------------------------------------------------------------

(source
(if_statement
condition: (bool)
Expand Down

0 comments on commit 7bedd9a

Please sign in to comment.