Skip to content

Commit

Permalink
Fix for RT #119521
Browse files Browse the repository at this point in the history
- now returns Nil if there's no more OUTER to be found
- perhaps this should be a Failure instead, but Nil seemed more appropriate to me
- also fixed this for OUTERS::
  • Loading branch information
lizmat committed Dec 2, 2017
1 parent f768623 commit cd24b1c
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions src/core/PseudoStash.pm
Expand Up @@ -54,14 +54,20 @@ my class PseudoStash is Map {
},
'OUTER' => sub ($cur) {
my Mu $ctx := nqp::ctxouterskipthunks(
nqp::getattr(nqp::decont($cur), PseudoStash, '$!ctx'));
my $stash := nqp::create(PseudoStash);
nqp::bindattr($stash, Map, '$!storage', nqp::ctxlexpad($ctx));
nqp::bindattr($stash, PseudoStash, '$!ctx', $ctx);
nqp::bindattr_i($stash, PseudoStash, '$!mode', PRECISE_SCOPE);
nqp::setwho(
Metamodel::ModuleHOW.new_type(:name('OUTER')),
$stash);
nqp::getattr(nqp::decont($cur),PseudoStash,'$!ctx'));

if nqp::isnull($ctx) {
Nil
}
else {
my $stash := nqp::create(PseudoStash);
nqp::bindattr($stash, Map, '$!storage', nqp::ctxlexpad($ctx));
nqp::bindattr($stash, PseudoStash, '$!ctx', $ctx);
nqp::bindattr_i($stash, PseudoStash, '$!mode', PRECISE_SCOPE);
nqp::setwho(
Metamodel::ModuleHOW.new_type(:name('OUTER')),
$stash)
}
},
'LEXICAL' => sub ($cur) {
my $stash := nqp::clone($cur);
Expand All @@ -73,13 +79,19 @@ my class PseudoStash is Map {
'OUTERS' => sub ($cur) {
my Mu $ctx := nqp::ctxouterskipthunks(
nqp::getattr(nqp::decont($cur), PseudoStash, '$!ctx'));
my $stash := nqp::create(PseudoStash);
nqp::bindattr($stash, Map, '$!storage', nqp::ctxlexpad($ctx));
nqp::bindattr($stash, PseudoStash, '$!ctx', $ctx);
nqp::bindattr_i($stash, PseudoStash, '$!mode', STATIC_CHAIN);
nqp::setwho(
Metamodel::ModuleHOW.new_type(:name('OUTERS')),
$stash);

if nqp::isnull($ctx) {
Nil
}
else {
my $stash := nqp::create(PseudoStash);
nqp::bindattr($stash, Map, '$!storage', nqp::ctxlexpad($ctx));
nqp::bindattr($stash, PseudoStash, '$!ctx', $ctx);
nqp::bindattr_i($stash, PseudoStash, '$!mode', STATIC_CHAIN);
nqp::setwho(
Metamodel::ModuleHOW.new_type(:name('OUTERS')),
$stash)
}
},
'DYNAMIC' => sub ($cur) {
my $stash := nqp::clone($cur);
Expand Down

0 comments on commit cd24b1c

Please sign in to comment.