summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorDagfinn Ilmari Mannsåker <ilmari@ilmari.org>2015-10-06 23:13:31 +0100
committerTony Cook <tony@develop-help.com>2015-10-12 15:21:45 +1100
commit0f948285b1d20fc918c76b133dd5bf40d0fa1221 (patch)
treeda0aebfee340547ad496eddc36c25b5725b1a387 /op.c
parent4a21999a595cf89f78d57aa5b3fdf3fbfa638fb1 (diff)
downloadperl-0f948285b1d20fc918c76b133dd5bf40d0fa1221.tar.gz
Include the name of the non-lvalue sub in error message
This makes the cause of the error more obvious if you accidentally call a non-lvalue sub in the final position of an lvalue one.
Diffstat (limited to 'op.c')
-rw-r--r--op.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/op.c b/op.c
index 0d04858b5d..0c2af88c64 100644
--- a/op.c
+++ b/op.c
@@ -2792,6 +2792,7 @@ Perl_op_lvalue_flags(pTHX_ OP *o, I32 type, U32 flags)
OP *kid = cUNOPo->op_first;
CV *cv;
GV *gv;
+ SV *namesv;
if (kid->op_type != OP_PUSHMARK) {
if (kid->op_type != OP_NULL || kid->op_targ != OP_LIST)
@@ -2829,6 +2830,15 @@ Perl_op_lvalue_flags(pTHX_ OP *o, I32 type, U32 flags)
break;
if (CvLVALUE(cv))
break;
+ if (flags & OP_LVALUE_NO_CROAK)
+ return NULL;
+
+ namesv = cv_name(cv, NULL, 0);
+ yyerror_pv(Perl_form(aTHX_ "Can't modify non-lvalue "
+ "subroutine call of &%"SVf" in %s",
+ SVfARG(namesv), PL_op_desc[type]),
+ SvUTF8(namesv));
+ return o;
}
}
/* FALLTHROUGH */
@@ -2842,9 +2852,7 @@ Perl_op_lvalue_flags(pTHX_ OP *o, I32 type, U32 flags)
yyerror(Perl_form(aTHX_ "Can't modify %s in %s",
(o->op_type == OP_NULL && (o->op_flags & OPf_SPECIAL)
? "do block"
- : (o->op_type == OP_ENTERSUB
- ? "non-lvalue subroutine call"
- : OP_DESC(o))),
+ : OP_DESC(o)),
type ? PL_op_desc[type] : "local"));
return o;