diff options
author | Father Chrysostomos <sprout@cpan.org> | 2016-04-24 18:19:59 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2016-05-16 20:22:02 -0700 |
commit | dc26b617fb7e7efe5ade0b25317c4133355b1cab (patch) | |
tree | 951ee62fa6e1eb1d72793cf94f0f893f03ee90cf | |
parent | f861ba6781c5332f6aee9858ce7f69b9ff26f55f (diff) | |
download | perl-dc26b617fb7e7efe5ade0b25317c4133355b1cab.tar.gz |
[perl #127976] Use yyerror for each $scalar error
yyerror queues the error, allowing for multiple error messages for
syntax errors. So at compile time it is generally better than croak.
It also provides more information about the location of the error,
with things like ‘at EOF’ and ‘near such and such’.
The hash functions each, values, and keys were using croak for the
‘Experimental forbidden’ message, unlike the array functions, which
were already using yyerror.
This commit changes the hash functions to use yyerror.
-rw-r--r-- | op.c | 6 | ||||
-rw-r--r-- | t/op/smartkve.t | 6 |
2 files changed, 8 insertions, 4 deletions
@@ -11957,10 +11957,10 @@ Perl_ck_each(pTHX_ OP *o) /* we let ck_fun handle it */ break; default: - Perl_croak_nocontext( + yyerror_pv(Perl_form(aTHX_ "Experimental %s on scalar is now forbidden", - PL_op_desc[orig_type]); - break; + PL_op_desc[orig_type]), 0); + return o; } } return ck_fun(o); diff --git a/t/op/smartkve.t b/t/op/smartkve.t index c57bc6843a..fdd886ed14 100644 --- a/t/op/smartkve.t +++ b/t/op/smartkve.t @@ -15,7 +15,11 @@ plan 'no_plan'; my $empty; sub set_errpat { - $errpat = qr/Experimental $_[0] on scalar is now forbidden/; + # Checking for a comma after the line number ensures that we are using + # yyerror for the error, rather than croak. yyerror is preferable for + # compile-time errors. + $errpat = + qr/Experimental $_[0] on scalar is now forbidden .* line 1,/; } # Keys -- errors |