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

This commit is contained in:
Michel Hermier
2021-04-08 07:58:46 +02:00
committed by GitHub
parent fd1d095588
commit 059e407ed3
2 changed files with 25 additions and 0 deletions

View File

@ -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)
{
@ -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;

View File

@ -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(
)