develooper Front page | perl.cvs.parrot | Postings from January 2009

[svn:parrot] r35870 - trunk/languages/perl6/src/parser

From:
jonathan
Date:
January 21, 2009 10:01
Subject:
[svn:parrot] r35870 - trunk/languages/perl6/src/parser
Message ID:
20090121180148.F41F6CB9AE@x12.develooper.com
Author: jonathan
Date: Wed Jan 21 10:01:48 2009
New Revision: 35870

Modified:
   trunk/languages/perl6/src/parser/actions.pm

Log:
[rakudo] If we take a type as a parameter, we should just bind the parameter 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.

Modified: trunk/languages/perl6/src/parser/actions.pm
==============================================================================
--- trunk/languages/perl6/src/parser/actions.pm	(original)
+++ trunk/languages/perl6/src/parser/actions.pm	Wed Jan 21 10:01:48 2009
@@ -1167,15 +1167,16 @@
     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
@@ -1207,7 +1208,7 @@
     ##  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' {



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About