Subject: | t/08-hash.t fails when compiling nested rules for 8th test |
Tests in 0.37 version compiled with perl 5.14.1 do not pass:
$ prove --blib -v t/08-hash.t
t/08-hash.t ..
1..8
ok 1 - use Pugs::Compiler::Rule;
ok 2 - Matched hash{iff}
ok 3 - fail hash{if} - value != 1
ok 4 - closure not called yet
ok 5 - closure was called hash{use}
ok 6 - subrule hash{until}
ok 7 - subrule hash{until} - 2
Error in evaluation: Couldn't find '%test' in surrounding lexical scope.
at
/home/test/fedora/perl-Pugs-Compiler-Rule/Pugs-Compiler-Rule-0.37/blib/lib/Pugs/Compiler/Regex.pm
line 132
Source:
do {
package Pugs::Runtime::Regex;
my $matcher =
concat(
constant( q!x! )
, constant( q!x! )
, hash( get_variable( '%test' ) )
, constant( q!y! )
, constant( q!y! )
)
;
my $rule;
$rule = sub {
my $tree;
if ( defined $_[3]{p}
&& ! $_[3]{continue}
) {
$matcher->( $_[1], $_[2], $tree, $tree, $_[0], $_[3]{p}, $_[1],
$_[3] );
}
else {
$_[3]{p} ||= 0;
for my $pos ( $_[3]{p} .. length( $_[1] ) ) {
my $param = { %{$_[3]}, p => $pos };
$matcher->( $_[1], $_[2], $tree, $tree, $_[0], $pos, $_[1],
$param );
last if $tree;
}
$tree = Pugs::Grammar::Base->no_match(@_)
unless defined $tree;
}
my $cap = $tree->data->{capture};
if ( ref $cap eq 'CODE' ) {
$::_V6_MATCH_ = $tree;
$tree->data->{capture} = \($cap->( $tree ));
};
if ( $tree ) {
# $::_V6_PRIOR_ = $rule
my $prior = $::_V6_PRIOR_;
$::_V6_PRIOR_ = sub {
local $main::_V6_PRIOR_ = $prior;
$rule->(@_);
};
}
return $tree;
}
}
# Looks like you planned 8 tests but ran 7.
# Looks like your test exited with 255 just after 7.
Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 1/8 subtests
This is caused by recursive reference at t/08-hash.t:51:
my %test = (
rule1 => Pugs::Compiler::Regex->compile('xx %test yy'),
rule2 => Pugs::Compiler::Regex->compile('abc'),
);