Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Allow bareword GLOBAL:: package identifier.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Nov 20, 2009
1 parent ecce4ce commit b387ccf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
11 changes: 4 additions & 7 deletions src/NQP/Actions.pm
Expand Up @@ -478,14 +478,11 @@ method term:sym<identifier>($/) {
}

method term:sym<name>($/) {
my $ns := $<name><identifier>;
$ns := Q:PIR {
$P0 = find_lex '$ns'
%r = clone $P0
};
my $name := $ns.pop;
my @ns := pir::clone__PP($<name><identifier>);
my $name := @ns.pop;
@ns.shift if @ns && @ns[0] eq 'GLOBAL';
my $var :=
PAST::Var.new( :name(~$name), :namespace($ns), :scope('package') );
PAST::Var.new( :name(~$name), :namespace(@ns), :scope('package') );
my $past := $var;
if $<args> {
$past := $<args>[0].ast;
Expand Down
7 changes: 6 additions & 1 deletion t/nqp/43-package-var.t
Expand Up @@ -2,14 +2,16 @@

# Accessing package variables directly

plan(4);
plan(5);

our $var;

$GLOBAL::var := 1;
$ABC::def := 2;
@XYZ::ghi[0] := 3;
$GLOBAL::context := 4;
GLOBAL::mysub := { ok(5, 'bare GLOBAL works'); };


ok( $var == 1, '$GLOBAL::var works');

Expand All @@ -25,3 +27,6 @@ module XYZ {
}

ok( $*context == 4, 'contextual in GLOBAL works');

mysub();

0 comments on commit b387ccf

Please sign in to comment.