File tree Expand file tree Collapse file tree 1 file changed +52
-1
lines changed Expand file tree Collapse file tree 1 file changed +52
-1
lines changed Original file line number Diff line number Diff line change 6
6
set_up_inc(' ../lib' );
7
7
}
8
8
9
- plan(tests => 170 );
9
+ plan(tests => 172 );
10
10
11
11
eval ' pass();' ;
12
12
@@ -392,6 +392,57 @@ our $x = 1;
392
392
is($d7 -> (), 3);
393
393
}
394
394
395
+ {
396
+ # github 22547
397
+ # these produce the expected results with 5.40.0
398
+ local $TODO = " eval from DB outside chain is broken" ;
399
+ fresh_perl_is(<<'CODE' , " 1.1\n 1.2\n 2\n " , {}, " lexical lookup from DB::" );
400
+ use builtin qw(ceil);
401
+ use strict;
402
+
403
+ package DB {
404
+ sub do_eval { eval shift or $@; }
405
+ }
406
+
407
+ {
408
+ my $xx = 1.2;
409
+ my sub f {
410
+ print DB::do_eval(shift), "\n";
411
+ }
412
+ f('1.1');
413
+ f('$xx');
414
+ f('ceil(1.1)');
415
+ }
416
+ CODE
417
+
418
+ # subtley different, one of the suggested solutions was to make
419
+ # CvOUTSIDE a weak reference, but in the case below $f exits before
420
+ # the eval is called, so the outside link from the closure it returns
421
+ # would break for a weak reference.
422
+ fresh_perl_is(<<'CODE' , " 1.1\n 1.2\n 2\n " , {}, " lexical lookup from DB::" );
423
+ use strict;
424
+
425
+ package DB {
426
+ sub do_eval { eval shift or $@; }
427
+ }
428
+
429
+ sub g {
430
+ my $yy;
431
+ my $f = sub {
432
+ $yy; # closure
433
+ use builtin qw(ceil);
434
+ our $xx = 1.2;
435
+ my $yy = shift;
436
+ return sub { print DB::do_eval($yy) || $@, "\n" };
437
+ };
438
+ return $f->(shift);
439
+ }
440
+ g('1.1')->();
441
+ g('$xx')->();
442
+ g('ceil(1.1)')->();
443
+ CODE
444
+ }
445
+
395
446
# [perl #19022] used to end up with shared hash warnings
396
447
# The program should generate no output, so anything we see is on stderr
397
448
my $got = runperl (prog => ' $h{a}=1; foreach my $k (keys %h) {eval qq{\$k}}' ,
You can’t perform that action at this time.
0 commit comments