diff --git a/lib/_007/Parser/Actions.pm6 b/lib/_007/Parser/Actions.pm6 index a0e73381..a8919957 100644 --- a/lib/_007/Parser/Actions.pm6 +++ b/lib/_007/Parser/Actions.pm6 @@ -217,7 +217,7 @@ class _007::Parser::Actions { make Q::TraitList.new(:traits(Val::Array.new(:elements(@traits)))); } method trait($/) { - make Q::Trait.new(:identifier($.ast), :expr($.ast)); + make Q::Trait.new(:identifier($.ast), :expr(ast-if-any($))); } method blockoid ($/) { diff --git a/lib/_007/Parser/Syntax.pm6 b/lib/_007/Parser/Syntax.pm6 index 0d42874d..ad74f65e 100644 --- a/lib/_007/Parser/Syntax.pm6 +++ b/lib/_007/Parser/Syntax.pm6 @@ -112,7 +112,7 @@ grammar _007::Parser::Syntax { * } token trait { - is» <.ws> '(' ')' + is» <.ws> [<.ws> '(' <.ws> ')']? } # requires a <.newpad> before invocation diff --git a/t/features/funcs.t b/t/features/funcs.t index e292b6b8..487e05b6 100644 --- a/t/features/funcs.t +++ b/t/features/funcs.t @@ -268,4 +268,16 @@ use _007::Test; outputs $program, "\n", "an anonymous func stringifies without a name"; } +{ + my $program = q:to/./; + func foo() is test { + say("OH HAI"); + } + + foo(); + . + + outputs $program, "OH HAI\n", "traits don't have to be followed by parentheses"; +} + done-testing;