@@ -425,18 +425,14 @@ class NQP::Actions is HLL::Actions {
425
425
$ past . viviself( vivitype( $ < sigil > ) );
426
426
}
427
427
elsif $ < twigil > [0 ] eq ' *' {
428
+ my $ global_fallback := lexical_package_lookup([' GLOBAL' , ~ $ < sigil > ~ $ < desigilname > ], $/ );
429
+ $ global_fallback . viviself(PAST::Op. new (
430
+ ' Contextual ' ~ ~ $/ ~ ' not found' ,
431
+ : pirop(' die' )
432
+ ));
428
433
$ past := PAST::Var. new (
429
434
: name(~ @ name . pop ), : scope(' contextual' ),
430
- : viviself(
431
- PAST::Var. new (
432
- : scope(' package' ), : namespace(' ' ),
433
- : name( ~ $ < sigil > ~ $ < desigilname > ),
434
- : viviself(
435
- PAST::Op. new ( ' Contextual ' ~ ~ $/ ~ ' not found' ,
436
- : pirop(' die' ) )
437
- )
438
- )
439
- )
435
+ : viviself($ global_fallback )
440
436
);
441
437
}
442
438
elsif $ < twigil > [0 ] eq ' !' {
@@ -1398,11 +1394,15 @@ class NQP::Actions is HLL::Actions {
1398
1394
}
1399
1395
1400
1396
# Otherwise, see if the first part of the name is lexically
1401
- # known. If not, it's in GLOBAL.
1397
+ # known. If not, it's in GLOBAL. Also, if first part is GLOBAL
1398
+ # then strip it off.
1402
1399
else {
1403
1400
my $ path := is_lexical(@ name [0 ]) ??
1404
1401
PAST::Var. new ( : name(@ name . shift ()), : scope(' lexical' ) ) !!
1405
1402
PAST::Var. new ( : name(' GLOBAL' ), : namespace([]), : scope(' package' ) );
1403
+ if @ name [0 ] eq ' GLOBAL' {
1404
+ @ name . shift ();
1405
+ }
1406
1406
for @ name {
1407
1407
$ path := PAST::Op. new (
1408
1408
: pirop(' nqp_get_package_through_who PPs' ),
0 commit comments