Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Catch undeclared variables properly.

  • Loading branch information...
commit a0b4c579cb03fde2f4a3bc3b0c24e0ee75f67cae 1 parent 81e9c47
@jnthn jnthn authored
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;
Please sign in to comment.
Something went wrong with that request. Please try again.