Skip to content

Commit

Permalink
[rakudo] If we take a type as a parameter, we should just bind the pa…
Browse files Browse the repository at this point in the history
…rameter directly do that name, not treat it as if it's a type capture. Otherwise, we get wrong answers in various cases, such as when parametric roles are parameterized with other roles.

git-svn-id: https://svn.parrot.org/parrot/trunk@35870 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
jnthn committed Jan 21, 2009
1 parent 4dd0906 commit d7c19f5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions languages/perl6/src/parser/actions.pm
Expand Up @@ -1167,15 +1167,16 @@ method parameter($/) {
my $quant := $<quant>;

## if it was type a type capture and nothing else, need to make a PAST::Var
my $types_handled := 0;
unless $<param_var> {
unless $<type_constraint> == 1 {
unless +@($<type_constraint>) == 1 {
$/.panic("Invalid signature; cannot have two consecutive parameter separators.");
}
our @?BLOCK;
my $name := ~$<type_constraint>[0];
$var := PAST::Var.new( :scope('parameter') );
$var.name($var.unique());
my $name := substr($<type_constraint>[0].text(), 2); # knock off ::
$var := PAST::Var.new( :name($name), :scope('parameter') );
@?BLOCK[0].symbol( $var.name(), :scope('lexical') );
$types_handled := 1;
}

## handle slurpy and optional flags
Expand Down Expand Up @@ -1207,7 +1208,7 @@ method parameter($/) {
## keep track of any type constraints
my $typelist := PAST::Op.new( :name('all'), :pasttype('call') );
$var<type> := $typelist;
if $<type_constraint> {
if !$types_handled && $<type_constraint> {
for @($<type_constraint>) {
my $type_past := $( $_ );
if $type_past.isa(PAST::Var) && $type_past.scope() eq 'lexical' {
Expand Down

0 comments on commit d7c19f5

Please sign in to comment.