forked from Mirror/wren
wren/compiler: Allow multiline empty parameter lists and calls. (#925)
This commit is contained in:
@ -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;
|
||||
|
||||
|
||||
19
test/language/method/no_parameters_new_line.wren
Normal file
19
test/language/method/no_parameters_new_line.wren
Normal 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(
|
||||
)
|
||||
Reference in New Issue
Block a user