In perl.git, the branch blead has been updated <https://perl5.git.perl.org/perl.git/commitdiff/833d07d41793fe678f93433fca9520ec1a22f750?hp=8779d80ae74c415b57b9d139bb415e167292cd2a>
- Log ----------------------------------------------------------------- commit 833d07d41793fe678f93433fca9520ec1a22f750 Author: Father Chrysostomos <spr...@cpan.org> Date: Fri Dec 1 18:47:58 2017 -0800 [perl #132527] Allow 4-arg substr(delete ...) Commit 19a8de4862 broke 4-arg substr with ‘delete’ (and various other ops) for its first argument. Since historically these have been allowed, use a ‘loose’ lvalue context such as entersub when lvaluify- ing the first argument. commit 44626bc98dce9dce5689298504e30ed86a7e0a0a Author: Father Chrysostomos <spr...@cpan.org> Date: Sun Nov 26 18:46:56 2017 -0800 t/lib/warnings/9enabled: update comment This new description of the file better reflecst what it is actually used for now. ----------------------------------------------------------------------- Summary of changes: op.c | 5 ++++- t/lib/warnings/9enabled | 3 ++- t/op/substr.t | 11 ++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/op.c b/op.c index 7e7727a674..7030af0778 100644 --- a/op.c +++ b/op.c @@ -13388,7 +13388,10 @@ Perl_ck_substr(pTHX_ OP *o) if (kid->op_type == OP_NULL) kid = OpSIBLING(kid); if (kid) - op_lvalue(kid, o->op_type); + /* Historically, substr(delete $foo{bar},...) has been allowed + with 4-arg substr. Keep it working by applying entersub + lvalue context. */ + op_lvalue(kid, OP_ENTERSUB); } return o; diff --git a/t/lib/warnings/9enabled b/t/lib/warnings/9enabled index 7cf2c5d58d..6d8bd64acf 100644 --- a/t/lib/warnings/9enabled +++ b/t/lib/warnings/9enabled @@ -1,4 +1,5 @@ -Check warnings::enabled & warnings::warn +Check warnings::enabled, warnings::warn and other functionality of +warnings.pm. __END__ diff --git a/t/op/substr.t b/t/op/substr.t index dade46d99f..9becaf77d1 100644 --- a/t/op/substr.t +++ b/t/op/substr.t @@ -22,7 +22,7 @@ $SIG{__WARN__} = sub { } }; -plan(399); +plan(400); run_tests() unless caller; @@ -909,4 +909,13 @@ fresh_perl_is('$0 = "/usr/bin/perl"; substr($0, 0, 0, $0)', '', {}, "(perl #1293 is $#ta, 23; } +{ # [perl #132527] + use feature 'refaliasing'; + no warnings 'experimental::refaliasing'; + my $h; + \$h{foo} = \(my $bar = "baz"); + substr delete $h{foo}, 1, 1, o=>; + is $bar, boz => 'first arg to 4-arg substr is loose lvalue context'; +} + 1; -- Perl5 Master Repository