Author: pmichaud
Date: Sun Jan 4 22:31:54 2009
New Revision: 34962
Modified:
branches/rvar/languages/perl6/src/parser/actions.pm
Log:
[rakudo]: Throw exception on attempts to define attributes outside of classes
Modified: branches/rvar/languages/perl6/src/parser/actions.pm
==============================================================================
--- branches/rvar/languages/perl6/src/parser/actions.pm (original)
+++ branches/rvar/languages/perl6/src/parser/actions.pm Sun Jan 4 22:31:54 2009
@@ -1324,6 +1324,9 @@
my $sym := ~$<sym>;
my $past;
if $key eq 'open' {
+ our $?BLOCK_OPEN;
+ $?BLOCK_OPEN := PAST::Block.new( PAST::Stmts.new(), :node($/) );
+ $?BLOCK_OPEN<pkgdecl> := $sym;
@?PKGDECL.unshift( $sym );
}
else {
@@ -1460,6 +1463,12 @@
}
if $scope eq 'attribute' {
+ my $pkgdecl := $block<pkgdecl>;
+ unless $pkgdecl eq 'class' || $pkgdecl eq 'role'
+ || $pkgdecl eq 'grammar' {
+ $/.panic("Attempt to define attribute " ~ $var.name() ~
+ " outside of class, role, or grammar");
+ }
# Attribute declaration. Add code to the beginning
# of the block (really class/grammar/role) to
# create the attribute.