This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Rewrap one perldiag entry for better splain output
[perl5.git] / pod / perldiag.pod
index e52d4f4..7ad93c2 100644 (file)
@@ -170,34 +170,6 @@ alternatives.
 
 (F) msgsnd() requires a string at least as long as sizeof(long).
 
-=item %s argument is not a HASH or ARRAY element or a subroutine
-
-(F) The argument to exists() must be a hash or array element or a
-subroutine with an ampersand, such as:
-
-    $foo{$bar}
-    $ref->{"susie"}[12]
-    &do_something
-
-=item %s argument is not a HASH or ARRAY element or slice
-
-(F) The argument to delete() must be either a hash or array element,
-such as:
-
-    $foo{$bar}
-    $ref->{"susie"}[12]
-
-or a hash or array slice, such as:
-
-    @foo[$bar, $baz, $xyzzy]
-    @{$ref->[12]}{"susie", "queue"}
-
-=item %s argument is not a subroutine name
-
-(F) The argument to exists() for C<exists &sub> must be a subroutine
-name, and not a subroutine call.  C<exists &sub()> will generate this
-error.
-
 =item Argument "%s" isn't numeric%s
 
 (W numeric) The indicated string was fed as an argument to an operator
@@ -214,6 +186,13 @@ point and did not attempt to push this layer.  If your program
 didn't explicitly request the failing operation, it may be the
 result of the value of the environment variable PERLIO.
 
+=item Argument "%s" treated as 0 in increment (++)
+
+(W numeric) The indicated string was fed as an argument to the C<++>
+operator which expects either a number or a string matching
+C</^[a-zA-Z]*[0-9]*\z/>.  See L<perlop/Auto-increment and
+Auto-decrement> for details.
+
 =item Array @%s missing the @ in argument %d of %s()
 
 (D deprecated) Really old Perl let you omit the @ on array names in some
@@ -1683,6 +1662,30 @@ discovered.
 (F) You said something like "use Module 42" but in the Module file
 there are neither package declarations nor a C<$VERSION>.
 
+=item delete argument is index/value array slice, use array slice
+
+(F) You used index/value array slice syntax (C<%array[...]>) as
+the argument to C<delete>.  You probably meant C<@array[...]> with
+an @ symbol instead.
+
+=item delete argument is key/value hash slice, use hash slice
+
+(F) You used key/value hash slice syntax (C<%hash{...}>) as the argument to
+C<delete>.  You probably meant C<@hash{...}> with an @ symbol instead.
+
+=item delete argument is not a HASH or ARRAY element or slice
+
+(F) The argument to C<delete> must be either a hash or array element,
+such as:
+
+    $foo{$bar}
+    $ref->{"susie"}[12]
+
+or a hash or array slice, such as:
+
+    @foo[$bar, $baz, $xyzzy]
+    @{$ref->[12]}{"susie", "queue"}
+
 =item Delimiter for here document is too long
 
 (F) In a here document construct like C<<<FOO>, the label C<FOO> is too
@@ -1897,6 +1900,20 @@ OS.  See L<perlport>.
 
 (F) The final summary message when a Perl compilation fails.
 
+=item exists argument is not a HASH or ARRAY element or a subroutine
+
+(F) The argument to C<exists> must be a hash or array element or a
+subroutine with an ampersand, such as:
+
+    $foo{$bar}
+    $ref->{"susie"}[12]
+    &do_something
+
+=item exists argument is not a subroutine name
+
+(F) The argument to C<exists> for C<exists &sub> must be a subroutine name,
+and not a subroutine call.  C<exists &sub()> will generate this error.
+
 =item Exiting eval via %s
 
 (W exiting) You are exiting an eval by unconventional means, such as a
@@ -2170,8 +2187,8 @@ has since been undefined.
 <-- HERE in m/%s/
 
 (F) Group names must follow the rules for perl identifiers, meaning
-they must start with a non-digit word character. A common cause of
-this error is using (?&0) instead of (?0). See L<perlre>.
+they must start with a non-digit word character.  A common cause of
+this error is using (?&0) instead of (?0).  See L<perlre>.
 
 =item ()-group starts with a count
 
@@ -2230,8 +2247,10 @@ offending digit.
 
 =item Illegal character after '_' in prototype for %s : %s
 
-(W illegalproto) An illegal character was found in a prototype declaration.
-Legal characters in prototypes are $, @, %, *, ;, [, ], &, \, and +.
+(W illegalproto) An illegal character was found in a prototype
+declaration.  The '_' in a prototype must be followed by a ';',
+indicating the rest of the parameters are optional, or one of '@'
+or '%', since those two will accept 0 or more final parameters.
 
 =item Illegal character \%o (carriage return)
 
@@ -2491,6 +2510,12 @@ recognized by Perl or by a user-supplied handler.  See L<attributes>.
 the C<:alias> option to C<use charnames> and the specified character in
 the indicated name isn't valid.  See L<charnames/CUSTOM ALIASES>.
 
+=item Invalid \0 character in %s for %s: %s\0%s
+
+(W syscalls) Embedded \0 characters in pathnames or other system call
+arguments produce a warning as of 5.20.  The parts after the \0 were
+formerly ignored by system calls.
+
 =item Invalid character in \N{...}; marked by <-- HERE in \N{%s}
 
 (F) Only certain characters are valid for character names.  The
@@ -2614,7 +2639,7 @@ an arbitrary reference was blessed into the "version" class.
 (D regexp, deprecated) The two-character sequence C<"(*"> in
 this context in a regular expression pattern should be an
 indivisible token, with nothing intervening between the C<"(">
-and the C<"*">, but you separated them. Due to an accident of
+and the C<"*">, but you separated them.  Due to an accident of
 implementation, this prohibition was not enforced, but we do
 plan to forbid it in a future Perl version.  This message
 serves as giving you fair warning of this pending change.
@@ -2802,6 +2827,12 @@ foo :lvalue;> declaration before the definition.
 
 See also L<attributes.pm|attributes>.
 
+=item Magical list constants are not supported
+
+(F) You assigned a magical array to a stash element, and then tried
+to use the subroutine from the same slot.  You are asking Perl to do
+something it cannot do, details subject to change between Perl versions.
+
 =item Malformed integer in [] in pack
 
 (F) Between the brackets enclosing a numeric repeat count only digits
@@ -2979,6 +3010,11 @@ they have a name with which they can be found.
 are always mentioned with the $ in Perl, unlike in the shells, where it
 can vary from one line to the next.
 
+=item Missing ']' in prototype for %s : %s
+
+(W illegalproto) A grouping was started with C<[> but never closed with
+C<]>.
+
 =item (Missing operator before %s?)
 
 (S syntax) This is an educated guess made in conjunction with the message
@@ -3119,13 +3155,15 @@ local() if you want to localize a package variable.
 
 (W once) Typographical errors often show up as unique variable names.
 If you had a good reason for having a unique name, then just mention it
-again somehow to suppress the message.  The C<our> declaration is
-provided for this purpose.
+again somehow to suppress the message.  The C<our> declaration is provided
+for this purpose.
 
 NOTE: This warning detects symbols that have been used only once so $c, @c,
 %c, *c, &c, sub c{}, c(), and c (the filehandle or format) are considered
 the same; if a program uses $c only once but also uses any of the others it
-will not trigger this warning.
+will not trigger this warning.  Symbols beginning with an underscore and
+symbols using special identifiers (q.v. L<perldata>) are exempt from this
+warning.
 
 =item Need exactly 3 octal digits in regex; marked by <-- HERE in m/%s/
 
@@ -4016,12 +4054,10 @@ that a method requires a package that has not been loaded.
 =item Perl folding rules are not up-to-date for 0x%X; please use the perlbug 
 utility to report; in regex; marked by <-- HERE in m/%s/
 
-(D regexp, deprecated) You used a regular expression with
-case-insensitive matching, and there is a bug in Perl in which the
-built-in regular expression folding rules are not accurate.  This
-may lead to incorrect results.  Please report this as a bug using the
-L<perlbug> utility.  (This message is marked deprecated, so that it by
-default will be turned-on.)
+(S regexp) You used a regular expression with case-insensitive matching,
+and there is a bug in Perl in which the built-in regular expression
+folding rules are not accurate.  This may lead to incorrect results.
+Please report this as a bug using the L<perlbug> utility.
 
 =item Perl_my_%s() not available
 
@@ -4210,6 +4246,28 @@ Perl guesses a reasonable buffer size, but puts a sentinel byte at the
 end of the buffer just in case.  This sentinel byte got clobbered, and
 Perl assumes that memory is now corrupted.  See L<perlfunc/ioctl>.
 
+=item Possible precedence issue with control flow operator
+
+(W syntax) There is a possible problem with the mixing of a control
+flow operator (e.g. C<return>) and a low-precedence operator like
+C<or>.  Consider:
+
+    sub { return $a or $b; }
+
+This is parsed as:
+
+    sub { (return $a) or $b; }
+
+Which is effectively just:
+
+    sub { return $a; }
+
+Either use parentheses or the high-precedence variant of the operator.
+
+Note this may be also triggered for constructs like:
+
+    sub { 1 if die; }
+
 =item Possible precedence problem on bitwise %c operator
 
 (W precedence) Your program uses a bitwise logical operator in conjunction
@@ -4507,7 +4565,7 @@ supposed to be there.
 (P) A "can't happen" error, because safemalloc() should have caught it
 earlier.
 
-=item Repeated format line will never terminate (~~ and @# incompatible)
+=item Repeated format line will never terminate (~~ and @#)
 
 (F) Your format contains the ~~ repeat-until-blank sequence and a
 numeric field that will never go blank so that the repetition never
@@ -4576,6 +4634,28 @@ as a list, you need to look into how references work, because Perl will
 not magically convert between scalars and lists for you.  See
 L<perlref>.
 
+=item Scalar value %%s[%s] better written as $%s[%s]
+
+(W syntax) In scalar context, you've used an array index/value slice
+(indicated by %) to select a single element of an array.  Generally
+it's better to ask for a scalar value (indicated by $).  The difference
+is that C<$foo[&bar]> always behaves like a scalar, both in the value it
+returns and when evaluating its argument, while C<%foo[&bar]> provides
+a list context to its subscript, which can do weird things if you're
+expecting only one subscript.  When called in list context, it also
+returns the index (what C<&bar> returns) in addition to the value.
+
+=item Scalar value %%s{%s} better written as $%s{%s}
+
+(W syntax) In scalar context, you've used a hash key/value slice
+(indicated by %) to select a single element of a hash.  Generally it's
+better to ask for a scalar value (indicated by $).  The difference
+is that C<$foo{&bar}> always behaves like a scalar, both in the value
+it returns and when evaluating its argument, while C<@foo{&bar}> and
+provides a list context to its subscript, which can do weird things
+if you're expecting only one subscript.  When called in list context,
+it also returns the key in addition to the value.
+
 =item Search pattern not terminated
 
 (F) The lexer couldn't find the final delimiter of a // or m{}
@@ -4940,6 +5020,11 @@ assignment or as a subroutine argument for example).
 (P) Perl tried to force the upgrade of an SV to a type which was actually
 inferior to its current type.
 
+=item SWASHNEW didn't return an HV ref
+
+(P) Something went wrong internally when Perl was trying to look up
+Unicode characters.
+
 =item Switch (?(condition)... contains too many branches in regex; marked by 
 <-- HERE in m/%s/
 
@@ -5136,7 +5221,7 @@ target of the change to
 
 (F) Something has attempted to use an internal API call which
 depends on Perl being compiled with the default support for randomized hash
-key traversal, but this Perl has been compiled without it. You should
+key traversal, but this Perl has been compiled without it.  You should
 report this warning to the relevant upstream party, or recompile perl
 with default options.
 
@@ -5379,6 +5464,16 @@ enough to figure out what you really meant.
 (P) When compiling a subroutine call in lvalue context, Perl failed an
 internal consistency check.  It encountered a malformed op tree.
 
+=item Unexpected exit %u
+
+(S) exit() was called or the script otherwise finished gracefully when
+C<PERL_EXIT_WARN> was set in C<PL_exit_flags>.
+
+=item Unexpected exit failure %u
+
+(S) An uncaught die() was called when C<PERL_EXIT_WARN> was set in
+C<PL_exit_flags>.
+
 =item Unexpected ')' in regex; marked by <-- HERE in m/%s/
 
 (F) You had something like this:
@@ -5474,7 +5569,7 @@ this error.  Likely what was meant instead was:
 
 (W) You tried to use an unknown subpragma of the "re" pragma.
 
-=item Unknown switch condition (?(%s in regex; marked by <-- HERE in m/%s/
+=item Unknown switch condition (?(...)) in regex; marked by <-- HERE in m/%s/
 
 (F) The condition part of a (?(condition)if-clause|else-clause) construct
 is not known.  The condition must be one of the following:
@@ -5497,7 +5592,7 @@ discovered.  See L<perlre>.
 (F) You specified an unknown Unicode option.  See L<perlrun> documentation
 of the C<-C> switch for the list of known options.
 
-=item Unknown Unicode option value %x
+=item Unknown Unicode option value %d
 
 (F) You specified an unknown Unicode option.  See L<perlrun> documentation
 of the C<-C> switch for the list of known options.
@@ -5916,9 +6011,9 @@ used.  (This may change in the future.)
 
 =item Use of each() on hash after insertion without resetting hash iterator results in undefined behavior
 
-(S internal) The behavior of C<each()> after insertion is undefined; it may
-skip items, or visit items more than once. Consider using C<keys()> instead
-of C<each()>.
+(S internal) The behavior of C<each()> after insertion is undefined;
+it may skip items, or visit items more than once.  Consider using
+C<keys()> instead of C<each()>.
 
 =item Use of := for an empty attribute list is not allowed
 
@@ -6302,9 +6397,9 @@ before now.  Check your control flow.
 
 =item %s "\x%X" does not map to Unicode
 
-(F) When reading in different encodings, Perl tries to map
-everything into Unicode characters.  The bytes you read in
-are not legal in this encoding.  For example
+(S utf8) When reading in different encodings, Perl tries to
+map everything into Unicode characters.  The bytes you read
+in are not legal in this encoding.  For example
 
     utf8 "\xE4" does not map to Unicode