Skip to content
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

wren/compiler: Allow multiline empty parameter lists and calls. #925

Merged
merged 1 commit into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/vm/wren_compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1876,6 +1876,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 @@ -2547,6 +2550,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(
)