diff --git a/src/parser/actions.pm b/src/parser/actions.pm index a36f7d419d4..07d85b63356 100644 --- a/src/parser/actions.pm +++ b/src/parser/actions.pm @@ -1423,10 +1423,14 @@ method package_declarator($/, $key) { my $sym := ~$; my $past; if $key eq 'open' { + # Start of a package. Create a block and mark it as a package declaration. our $?BLOCK_OPEN; $?BLOCK_OPEN := PAST::Block.new( PAST::Stmts.new(), :node($/) ); $?BLOCK_OPEN := $sym; @?PKGDECL.unshift( $sym ); + + # Attach traits list to it. + $?BLOCK_OPEN := $; } elsif $key eq 'package_def' { make $.ast; diff --git a/src/parser/grammar.pg b/src/parser/grammar.pg index 51098c450ef..07721dbf9c5 100644 --- a/src/parser/grammar.pg +++ b/src/parser/grammar.pg @@ -702,8 +702,8 @@ rule package_def { match.'add_type'($S0) }} ]? - {*} #= open * + {*} #= open [ | {*} #= block |