]> git.vpit.fr Git - perl/modules/Scope-Upper.git/commitdiff
Adjust line number test for exception thrown from anonymous sub rt181699
authorVincent Pit <vpit@cpan.org>
Mon, 16 Nov 2026 10:09:46 +0000 (11:09 +0100)
committerVincent Pit <vpit@cpan.org>
Mon, 16 Nov 2026 10:09:50 +0000 (11:09 +0100)
The parser has been fixed in perl 5.45.4 to report the line number for
the sub keyword rather than the end of the anonymous sub. Thansk Richard
Leach for reporting and suggesting a fix.

This fixes [RT #181699]

t/63-uplevel-ctl.t

index fba2a687d25b178c922376db00b14a9974f96a18..8d6cbb1e3137b705fef0d037a3f7d651378fc216 100644 (file)
@@ -314,14 +314,15 @@ sub clash {
 # XS
 
 {
- my $desc = 'exception thrown from XS';
+ my $desc   = 'exception thrown from XS';
+ my $offset = "$]" >= 5.045004 ? 4 : 2; # Exception fires at target frame
  local $@;
  eval {
   sub {
    &uplevel(\&uplevel => \1, HERE);
   }->();
  };
- my $line = $^P ? '\d+' : __LINE__-2; # The error happens at the target frame.
+ my $line = $^P ? '\d+' : __LINE__ - $offset;
  my $file = $^P ? '\S+' : quotemeta $0;
  like $@,
    qr/^First argument to uplevel must be a code reference at $file line $line/,