summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-12-13 17:01:46 -0800
committerFather Chrysostomos <sprout@cpan.org>2013-12-13 18:06:59 -0800
commit92bd82a0bbf6e4ba85031c2761f405bdddc08c82 (patch)
tree6110c0e9bdeb3d02f1a14953d58c783b7e5136b6 /op.c
parent4612c2badededd35d182bfa43a95f28d725bc74c (diff)
downloadperl-92bd82a0bbf6e4ba85031c2761f405bdddc08c82.tar.gz
op.c: Factor out two identical yyerror calls
Diffstat (limited to 'op.c')
-rw-r--r--op.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/op.c b/op.c
index 4daba7a871..627486d02a 100644
--- a/op.c
+++ b/op.c
@@ -2796,6 +2796,16 @@ S_move_proto_attr(pTHX_ OP **proto, OP **attrs, const GV * name)
}
}
+static void
+S_cant_declare(pTHX_ OP *o)
+{
+ yyerror(Perl_form(aTHX_ "Can't declare %s in \"%s\"",
+ OP_DESC(o),
+ PL_parser->in_my == KEY_our ? "our" :
+ PL_parser->in_my == KEY_state ? "state" :
+ "my"));
+}
+
STATIC OP *
S_my_kid(pTHX_ OP *o, OP *attrs, OP **imopsp)
{
@@ -2825,11 +2835,7 @@ S_my_kid(pTHX_ OP *o, OP *attrs, OP **imopsp)
type == OP_RV2AV ||
type == OP_RV2HV) { /* XXX does this let anything illegal in? */
if (cUNOPo->op_first->op_type != OP_GV) { /* MJD 20011224 */
- yyerror(Perl_form(aTHX_ "Can't declare %s in \"%s\"",
- OP_DESC(o),
- PL_parser->in_my == KEY_our
- ? "our"
- : PL_parser->in_my == KEY_state ? "state" : "my"));
+ S_cant_declare(aTHX_ o);
} else if (attrs) {
GV * const gv = cGVOPx_gv(cUNOPo->op_first);
PL_parser->in_my = FALSE;
@@ -2848,11 +2854,7 @@ S_my_kid(pTHX_ OP *o, OP *attrs, OP **imopsp)
type != OP_PADHV &&
type != OP_PUSHMARK)
{
- yyerror(Perl_form(aTHX_ "Can't declare %s in \"%s\"",
- OP_DESC(o),
- PL_parser->in_my == KEY_our
- ? "our"
- : PL_parser->in_my == KEY_state ? "state" : "my"));
+ S_cant_declare(aTHX_ o);
return o;
}
else if (attrs && type != OP_PUSHMARK) {