diff --git a/src/Perl6/Actions.pm b/src/Perl6/Actions.pm index fca683ccc6e..c8ca1f74109 100644 --- a/src/Perl6/Actions.pm +++ b/src/Perl6/Actions.pm @@ -848,7 +848,12 @@ method declarator($/) { my $list := PAST::Op.new( :pasttype('call'), :name('&infix:<,>') ); my $decls := $.ast.get_declarations; for @($decls) { - $list.push(declare_variable($/, $_, $_, $_, $_, $_)); + if $_.isa(PAST::Var) { + $list.push(declare_variable($/, $_, $_, $_, $_, $_)); + } + else { + $list.push($_); + } } $list := $.ast; make $list; @@ -2597,8 +2602,10 @@ sub add_signature($block, $sig_obj, $lazy) { $block[0].push(PAST::Var.new( :name('call_sig'), :scope('parameter'), :call_sig(1) )); my $decls := $sig_obj.get_declarations(); for @($decls) { - $_.isdecl(1); - $block.symbol( $_.name, :scope('lexical') ); + if $_.isa(PAST::Var) { + $_.isdecl(1); + $block.symbol( $_.name, :scope('lexical') ); + } } $block[0].push($decls); $block[0].push(PAST::Op.new( diff --git a/src/Perl6/Compiler/Signature.pm b/src/Perl6/Compiler/Signature.pm index 72f3861d12c..34b99e08fe5 100644 --- a/src/Perl6/Compiler/Signature.pm +++ b/src/Perl6/Compiler/Signature.pm @@ -130,7 +130,7 @@ method get_declarations() { my @entries := self.entries; for @entries { # If the parameter has a name, add it. - if $_.var_name { + if pir::length($_.var_name) > 1 { my $var := PAST::Var.new( :name($_.var_name), :scope('lexical'), @@ -142,6 +142,15 @@ method get_declarations() { $var := $_.traits; $result.push($var); } + elsif pir::length($_.var_name) == 1 { + # A placeholder, but could be being used in a declaration, so emit + # a Whatever. + my @name := Perl6::Grammar::parse_name('Whatever'); + $result.push(PAST::Op.new( + :pasttype('callmethod'), :name('new'), :lvalue(1), + PAST::Var.new( :name(@name.pop), :namespace(@name), :scope('package') ) + )); + } # If there are captured type variables, need variables for those too. if $_.type_captures {