summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-02-08 17:14:10 -0800
committerFather Chrysostomos <sprout@cpan.org>2014-02-09 11:08:25 -0800
commita48e42054790d7e52df73e8a2c8b120da9ea6dc4 (patch)
tree9bc53152d37c696a75e61b3bdf0708cc46aad30e
parenta18bab6ebbe98d43ddd701fa7af24cad76eabe8c (diff)
downloadperl-a48e42054790d7e52df73e8a2c8b120da9ea6dc4.tar.gz
Use ‘an’ for $/=[] error message
This says ‘an ARRAY’: $ perl -Mstrict -e '@{"a"}' Can't use string ("a") as an ARRAY ref while "strict refs" in use at -e line 1. This says ‘a ARRAY’: $ ./miniperl -e '$/=[]' Setting $/ to a ARRAY reference is forbidden at -e line 1. It ought to say ‘an’.
-rw-r--r--mg.c4
-rw-r--r--pod/perldiag.pod16
-rw-r--r--t/base/rs.t4
3 files changed, 14 insertions, 10 deletions
diff --git a/mg.c b/mg.c
index 99a63f6844..c9bded4e0b 100644
--- a/mg.c
+++ b/mg.c
@@ -2769,7 +2769,9 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
);
}
} else {
- Perl_croak(aTHX_ "Setting $/ to a %s reference is forbidden", reftype);
+ /* diag_listed_as: Setting $/ to %s reference is forbidden */
+ Perl_croak(aTHX_ "Setting $/ to a%s %s reference is forbidden",
+ *reftype == 'A' ? "n" : "", reftype);
}
}
SvREFCNT_dec(PL_rs);
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index 06dd5d4e8f..96d95ad66f 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -4972,14 +4972,6 @@ didn't think so.
forget to check the return value of your socket() call? See
L<perlfunc/setsockopt>.
-=item Setting $/ to a %s reference is forbidden
-
-(F) You tried to assign a reference to a non integer to C<$/>. In older
-Perls this would have behaved similarly to setting it to a reference to
-a positive integer, where the integer was the address of the reference.
-As of Perl 5.20.0 this is a fatal error, to allow future versions of Perl
-to use non-integer refs for more interesting purposes.
-
=item Setting $/ to a reference to %s as a form of slurp is deprecated, treating as undef
(W deprecated) You assigned a reference to a scalar to C<$/> where the
@@ -4996,6 +4988,14 @@ You are recommended to change your code to set C<$/> to C<undef> explicitly
if you wish to slurp the file. In future versions of Perl assigning
a reference to will throw a fatal error.
+=item Setting $/ to %s reference is forbidden
+
+(F) You tried to assign a reference to a non integer to C<$/>. In older
+Perls this would have behaved similarly to setting it to a reference to
+a positive integer, where the integer was the address of the reference.
+As of Perl 5.20.0 this is a fatal error, to allow future versions of Perl
+to use non-integer refs for more interesting purposes.
+
=item shift on reference is experimental
(S experimental::autoderef) C<shift> with a scalar argument is experimental
diff --git a/t/base/rs.t b/t/base/rs.t
index b73ef4028d..416696e9f5 100644
--- a/t/base/rs.t
+++ b/t/base/rs.t
@@ -250,7 +250,9 @@ sub test_bad_setting {
} else {
my $msg= $@ || "Zombie Error";
print "ok ",$test_count++," # \$/ = []; should die\n";
- if ($msg!~m!Setting \$\/ to a ARRAY reference is forbidden!) {print "not ";}
+ if ($msg!~m!Setting \$\/ to an ARRAY reference is forbidden!) {
+ print "not ";
+ }
print "ok ",$test_count++," # \$/ = []; produced expected error message\n";
}
if (eval {$/ = {}; 1}) {