Skip to content

Commit

Permalink
Make positional captures stored in an Array again
Browse files Browse the repository at this point in the history
Apparently there are too many modules in the ecosystem depending on
this behaviour.  Basically reverts f627d2c
  • Loading branch information
lizmat committed Jun 14, 2020
1 parent 8134470 commit 6f6b2df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
12 changes: 4 additions & 8 deletions src/Perl6/bootstrap.c/BOOTSTRAP.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -3321,11 +3321,8 @@ BEGIN {
my $result := nqp::list();
my int $i := -1;
while ++$i < $n {
if nqp::atpos_i(@!pos-capture-counts, $i) >= 2 {
nqp::bindattr((my $List := nqp::create(List)),
List,'$!reified',nqp::list);
nqp::bindpos($result, $i, $List);
}
nqp::bindpos($result, $i, nqp::create(Array))
if nqp::atpos_i(@!pos-capture-counts, $i) >= 2;
}
$result
}
Expand All @@ -3349,10 +3346,9 @@ BEGIN {
my int $i := -1;
while ++$i < $n {
if nqp::atpos_i(@!named-capture-counts, $i) >= 2 {
nqp::bindattr((my $List := nqp::create(List)),
List,'$!reified',nqp::list);
nqp::bindkey($result,
nqp::atpos_s(@!named-capture-names, $i),$List);
nqp::atpos_s(@!named-capture-names, $i),
nqp::create(Array));
}
}
$result
Expand Down
20 changes: 4 additions & 16 deletions src/core.c/Match.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -123,25 +123,13 @@ my class Match is Capture is Cool does NQPMatchRole {
0
),
nqp::if( # positional capture
nqp::istype(
(my $p := nqp::atpos($list,$name)),
List
),
nqp::push(
nqp::getattr($p,List,'$!reified'),
$match
),
nqp::istype(nqp::atpos($list,$name),Array),
nqp::atpos($list,$name).push($match),
nqp::bindpos($list,$name,$match) # XXX
),
nqp::if( # named capture
nqp::istype(
(my $n := nqp::atkey($hash,$name)),
List
),
nqp::push(
nqp::getattr($n,List,'$!reified'),
$match
),
nqp::istype(nqp::atkey($hash,$name),Array),
nqp::atkey($hash,$name).push($match),
nqp::bindkey($hash,$name,$match) # XXX
)
)
Expand Down

0 comments on commit 6f6b2df

Please sign in to comment.