Permalink
Browse files

Catch undeclared variables properly.

  • Loading branch information...
1 parent 81e9c47 commit a0b4c579cb03fde2f4a3bc3b0c24e0ee75f67cae @jnthn jnthn committed Sep 30, 2012
Showing with 8 additions and 1 deletion.
  1. +8 −1 src/NQP/Actions.pm
View
9 src/NQP/Actions.pm
@@ -532,7 +532,14 @@ class NQP::Actions is HLL::Actions {
$past.fallback( default_for( $<sigil> ) );
}
else {
- $past := QAST::Var.new( :name(~@name.pop), :scope('lexical') );
+ my $name := ~@name.pop;
+ if $*IN_DECL eq 'variable' || $name eq '$_' || $name eq '$/'
+ || $name eq '$!' || $<twigil>[0] eq '?' || $*W.is_lexical($name) {
+ $past := QAST::Var.new( :name($name), :scope('lexical') );
+ }
+ else {
+ $/.CURSOR.panic("Use of undeclared variable '$name'");
+ }
}
}
make $past;

0 comments on commit a0b4c57

Please sign in to comment.