Skip to content

Commit 198aaf3

Browse files
author
Father Chrysostomos
committed
Don’t use yyerror for each($scalar) experiment err
This is a follow-up to 69e7f50. 69e7f50 resulted in yyerror being called twice for the same error, resulting in double diagnos- tics for where the error occurred: $ ./perl -e 'keys $scalar, $1' Experimental keys on scalar is now forbidden at -e line 1, near "$scalar," Type of arg 1 to keys must be hash or array (not scalar dereference) at -e line 1, near "$scalar," Execution of -e aborted due to compilation errors. We don’t need ‘near "$scalar,"’ twice. For the first one we should queue the error directly, using qerror() (which yyerror itself normally calls), so we don’t get double diagnostics.
1 parent ef55c67 commit 198aaf3

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

op.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11968,9 +11968,9 @@ Perl_ck_each(pTHX_ OP *o)
1196811968
)
1196911969
goto bad;
1197011970
default:
11971-
yyerror_pv(Perl_form(aTHX_
11971+
qerror(Perl_mess(aTHX_
1197211972
"Experimental %s on scalar is now forbidden",
11973-
PL_op_desc[orig_type]), 0);
11973+
PL_op_desc[orig_type]));
1197411974
bad:
1197511975
bad_type_pv(1, "hash or array", o, kid);
1197611976
return o;

t/op/smartkve.t

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ sub set_errpat {
1919
# yyerror for the error, rather than croak. yyerror is preferable for
2020
# compile-time errors.
2121
$errpat =
22-
qr/Experimental $_[0] on scalar is now forbidden .* line 1,(?x:
23-
).*Type of arg 1 to $_[0] must be hash or array \(not /s;
22+
qr/Experimental $_[0] on scalar is now forbidden .* line 1\.(?x:
23+
).*Type of arg 1 to $_[0] must be hash or array \(not (?x:
24+
).*line 1,/s;
2425
}
2526

2627
# Keys -- errors

0 commit comments

Comments
 (0)