This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Use ‘an’ for $/=[] error message
authorFather Chrysostomos <sprout@cpan.org>
Sun, 9 Feb 2014 01:14:10 +0000 (17:14 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 9 Feb 2014 19:08:25 +0000 (11:08 -0800)
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’.

mg.c
pod/perldiag.pod
t/base/rs.t

diff --git a/mg.c b/mg.c
index 99a63f6..c9bded4 100644 (file)
--- 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);
index 06dd5d4..96d95ad 100644 (file)
@@ -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
index b73ef40..416696e 100644 (file)
@@ -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}) {