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

Commit

Permalink
Browse files Browse the repository at this point in the history
Contextuals also look in the global namespace.
  • Loading branch information
pmichaud committed Nov 17, 2009
1 parent d7b50d4 commit 2925cff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/NQP/Actions.pm
Expand Up @@ -218,8 +218,15 @@ method variable($/) {
}
if $<twigil>[0] eq '*' {
$past.scope('contextual');
$past.viviself( PAST::Op.new( 'Contextual ' ~ ~$/ ~ ' not found',
:pirop('die') )
$past.viviself(
PAST::Var.new(
:scope('package'), :namespace(''),
:name( ~$<sigil> ~ $<desigilname> ),
:viviself(
PAST::Op.new( 'Contextual ' ~ ~$/ ~ ' not found',
:pirop('die') )
)
)
);
}
elsif $<twigil>[0] eq '!' {
Expand Down
5 changes: 4 additions & 1 deletion t/nqp/43-package-var.t
Expand Up @@ -2,13 +2,14 @@

# Accessing package variables directly

plan(3);
plan(4);

our $var;

$GLOBAL::var := 1;
$ABC::def := 2;
@XYZ::ghi[0] := 3;
$GLOBAL::context := 4;

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

Expand All @@ -22,3 +23,5 @@ module XYZ {
our @ghi;
ok( @ghi[0] == 3, '@XYZ::ghi works');
}

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

0 comments on commit 2925cff

Please sign in to comment.