Skip to content

Commit

Permalink
wren/compiler: Allow multiline empty parameter lists and calls. (#925)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhermier authored Apr 8, 2021
1 parent fd1d095 commit 059e407
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/vm/wren_compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1969,6 +1969,9 @@ static void methodCall(Compiler* compiler, Code instruction,
{
called.type = SIG_METHOD;

// Allow new line before an empty argument list
ignoreNewlines(compiler);

// Allow empty an argument list.
if (peek(compiler) != TOKEN_RIGHT_PAREN)
{
Expand Down Expand Up @@ -2640,6 +2643,9 @@ static void parameterList(Compiler* compiler, Signature* signature)

signature->type = SIG_METHOD;

// Allow new line before an empty argument list
ignoreNewlines(compiler);

// Allow an empty parameter list.
if (match(compiler, TOKEN_RIGHT_PAREN)) return;

Expand Down
19 changes: 19 additions & 0 deletions test/language/method/no_parameters_new_line.wren
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

class Foo {
static call(
) {
System.print("Success") // expect: Success
}

construct new () {}

call(
) {
System.print("Success") // expect: Success
}
}

Foo.call(
)
Foo.new().call(
)

0 comments on commit 059e407

Please sign in to comment.