diff --git a/op.c b/op.c index 594d4ee9c329..61f7eaad7513 100644 --- a/op.c +++ b/op.c @@ -4291,6 +4291,8 @@ Perl_op_lvalue_flags(pTHX_ OP *o, I32 type, U32 flags) switch (o->op_type) { case OP_UNDEF: + if (type == OP_SASSIGN) + goto nomod; PL_modcount++; goto do_next; diff --git a/t/run/fresh_perl.t b/t/run/fresh_perl.t index 5f0e2ce21682..88a64ad58391 100644 --- a/t/run/fresh_perl.t +++ b/t/run/fresh_perl.t @@ -194,8 +194,8 @@ BEGIN failed--compilation aborted at - line 1. ######## BEGIN { undef = 0 } EXPECT -Modification of a read-only value attempted at - line 1. -BEGIN failed--compilation aborted at - line 1. +Can't modify undef operator in scalar assignment at - line 1, near "0 }" +BEGIN not safe after errors--compilation aborted at - line 1. ######## { package foo;