In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/69e7f50e50fca481754ecdbf99128ec510592c89?hp=fe43a9cc030d741126b22f2730889e69452f8988>
- Log ----------------------------------------------------------------- commit 69e7f50e50fca481754ecdbf99128ec510592c89 Author: Father Chrysostomos <[email protected]> Date: Sun May 15 13:36:00 2016 -0700 [perl #127976] Restore âor arrayâ to each($s) err This part of the message was accidentally deleted when the autoderef feature was introduced. This commit also emits this error in addition to the âExperimental forbiddenâ message in those cases where the latter occurs, since it makes things clearer. M op.c M t/lib/croak/op M t/op/smartkve.t commit dc26b617fb7e7efe5ade0b25317c4133355b1cab Author: Father Chrysostomos <[email protected]> Date: Sun Apr 24 18:19:59 2016 -0700 [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. M op.c M t/op/smartkve.t commit f861ba6781c5332f6aee9858ce7f69b9ff26f55f Author: Father Chrysostomos <[email protected]> Date: Sun Apr 24 17:21:44 2016 -0700 startkve.t: Refactor setting of $errpat This will simplify things in the next commit. M t/op/smartkve.t commit acfbe606c0d84540e21a464268c3bc88bc187789 Author: Father Chrysostomos <[email protected]> Date: Sat Apr 23 22:33:48 2016 -0700 smartkve.t: Delete now-redundant tests The sole purpose of these tests was to make sure that the rvalues and reach ops had the OA_DANGEROUS flag set and consequently behaved correctly in list assignments that swap arguments. (See d86b3122 for details.) The tests were changed in commit 26230909, when the two ops in ques- tion were removed, to use plain values and each ops (without the r-), but those cases are already tested elsewhere by other tests that d86b3122 added. M t/op/smartkve.t ----------------------------------------------------------------------- Summary of changes: op.c | 11 ++++++----- t/lib/croak/op | 6 +++--- t/op/smartkve.t | 32 ++++++++++++-------------------- 3 files changed, 21 insertions(+), 28 deletions(-) diff --git a/op.c b/op.c index 9f7fbe5..cad8237 100644 --- a/op.c +++ b/op.c @@ -11954,13 +11954,14 @@ Perl_ck_each(pTHX_ OP *o) || ( SvTYPE(SvRV(cSVOPx_sv(kid))) != SVt_PVAV && SvTYPE(SvRV(cSVOPx_sv(kid))) != SVt_PVHV ) ) - /* we let ck_fun handle it */ - break; + goto bad; 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); + bad: + bad_type_pv(1, "hash or array", o, kid); + return o; } } return ck_fun(o); diff --git a/t/lib/croak/op b/t/lib/croak/op index cd3a654..6e19ff8 100644 --- a/t/lib/croak/op +++ b/t/lib/croak/op @@ -137,17 +137,17 @@ Execution of - aborted due to compilation errors. # NAME keys BAREWORD @a = keys FRED ; EXPECT -Type of arg 1 to keys must be hash (not constant item) at - line 1, near "FRED ;" +Type of arg 1 to keys must be hash or array (not constant item) at - line 1, near "FRED ;" Execution of - aborted due to compilation errors. ######## # NAME values BAREWORD @a = values FRED ; EXPECT -Type of arg 1 to values must be hash (not constant item) at - line 1, near "FRED ;" +Type of arg 1 to values must be hash or array (not constant item) at - line 1, near "FRED ;" Execution of - aborted due to compilation errors. ######## # NAME each BAREWORD @a = each FRED ; EXPECT -Type of arg 1 to each must be hash (not constant item) at - line 1, near "FRED ;" +Type of arg 1 to each must be hash or array (not constant item) at - line 1, near "FRED ;" Execution of - aborted due to compilation errors. diff --git a/t/op/smartkve.t b/t/op/smartkve.t index d93dde1..f092a8c 100644 --- a/t/op/smartkve.t +++ b/t/op/smartkve.t @@ -14,8 +14,17 @@ plan 'no_plan'; my $empty; +sub set_errpat { + # 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,(?x: + ).*Type of arg 1 to $_[0] must be hash or array \(not /s; +} + # Keys -- errors -$errpat = qr/Experimental keys on scalar is now forbidden/; +set_errpat 'keys'; eval "keys undef"; like($@, $errpat, @@ -46,7 +55,7 @@ like($@, $errpat, ) or print "# Got: $@"; # Values -- errors -$errpat = qr/Experimental values on scalar is now forbidden/; +set_errpat 'values'; eval "values undef"; like($@, $errpat, @@ -77,7 +86,7 @@ like($@, $errpat, ) or print "# Got: $@"; # Each -- errors -$errpat = qr/Experimental each on scalar is now forbidden/; +set_errpat 'each'; eval "each undef"; like($@, $errpat, @@ -106,20 +115,3 @@ eval q"each $hash qw/foo bar/"; like($@, $errpat, 'Errors: each $hash, @stuff throws error' ) or print "# Got: $@"; - -use feature 'refaliasing'; -my $a = 7; -our %h; -\$h{f} = \$a; -($a, $b) = each %h; -is "$a $b", "f 7", 'each %hash in list assignment'; -$a = 7; -($a, $b) = (3, values %h); -is "$a $b", "3 7", 'values %hash in list assignment'; -*a = sub { \@_ }->($a); -$a = 7; -($a, $b) = each our @a; -is "$a $b", "0 7", 'each @array in list assignment'; -$a = 7; -($a, $b) = (3, values @a); -is "$a $b", "3 7", 'values @array in list assignment'; -- Perl5 Master Repository
