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

[svn:parrot] r35244 - branches/rvar2/languages/perl6/src/parser

From:
pmichaud
Date:
January 8, 2009 22:03
Subject:
[svn:parrot] r35244 - branches/rvar2/languages/perl6/src/parser
Message ID:
20090109060254.51E83CB9F9@x12.develooper.com
Author: pmichaud
Date: Thu Jan  8 22:02:53 2009
New Revision: 35244

Modified:
   branches/rvar2/languages/perl6/src/parser/actions.pm

Log:
[rakudo]:  Make variable redeclarations a warning instead of fatal.


Modified: branches/rvar2/languages/perl6/src/parser/actions.pm
==============================================================================
--- branches/rvar2/languages/perl6/src/parser/actions.pm	(original)
+++ branches/rvar2/languages/perl6/src/parser/actions.pm	Thu Jan  8 22:02:53 2009
@@ -1524,7 +1524,7 @@
     if $past.isa(PAST::Op) {
         my $i := 0;
         for @($past) {
-            if $_.isa(PAST::Var) {
+            if $_.isa(PAST::Var) && !$_<redecl> {
                 my $var := $_;
 
                 # This is a variable declaration, so we set the scope in
@@ -1663,17 +1663,20 @@
     my $name   := $var.name();
     my $symbol := @?BLOCK[0].symbol( $name );
     if $symbol<scope> eq 'lexical' {
-        $/.panic("Redeclaration of variable " ~ $name);
+        warn("Redeclaration of variable " ~ $name);
+        $var<redecl> := 1;
+        $var.isdecl(0);
     }
-
-    $var.isdecl(1);
-    $var<type>  := PAST::Op.new( :name('and'), :pasttype('call') );
-    $var<itype> := container_itype($<variable><sigil>);
-
-    if $<trait> {
-        my $traitlist := PAST::Op.new( :name('infix:,'), :pasttype('call') );
-        $var<traitlist> := $traitlist;
-        for @($<trait>) { $traitlist.push( $( $_ ) ); }
+    else {
+        $var.isdecl(1);
+        $var<type>  := PAST::Op.new( :name('and'), :pasttype('call') );
+        $var<itype> := container_itype($<variable><sigil>);
+    
+        if $<trait> {
+            my $traitlist := PAST::Op.new( :name('infix:,'), :pasttype('call') );
+            $var<traitlist> := $traitlist;
+            for @($<trait>) { $traitlist.push( $( $_ ) ); }
+        }
     }
 
     make $var;



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