From 581af396908352663eb714834fb9f9ce3936d673 Mon Sep 17 00:00:00 2001 From: Ricardo Signes Date: Mon, 23 Apr 2012 18:56:29 -0400 Subject: [PATCH] perldelta: reorder bugfix sections and tweak one or two --- Porting/perl5160delta.pod | 1474 +++++++++++++++++++++++---------------------- 1 file changed, 740 insertions(+), 734 deletions(-) diff --git a/Porting/perl5160delta.pod b/Porting/perl5160delta.pod index 2c4caf5..2f6e09c 100644 --- a/Porting/perl5160delta.pod +++ b/Porting/perl5160delta.pod @@ -1707,246 +1707,152 @@ All the C files that make up the Perl core have been converted to UTF-8. =head1 Selected Bug Fixes -=head2 Regular expressions - -=for comment Is it possible to merge some of these items? - -=over 4 - -=item * - -C and C now use locale rules under -C when the platform supports that. Previously, they used -the platform's native character set. - -=item * - -C and C now match identically (when not -under a differing locale). This fixes a regression introduced in 5.14 -in which the first expression could match characters outside of ASCII, -such as the KELVIN SIGN. - -=item * +=head2 Array and hash -C would sometimes refuse to match at the end of a string that ends -with "\n". This has been fixed [perl #109206]. +=over =item * -Starting with 5.12.0, Perl used to get its internal bookkeeping muddled up -after assigning C<${ qr// }> to a hash element and locking it with -L. This could result in double frees, crashes or erratic -behaviour. +A bug has been fixed that would cause a "Use of freed value in iteration" +error if the next two hash elements that would be iterated over are +deleted [perl #85026]. (5.14.1) =item * -The new (in 5.14.0) regular expression modifier C when repeated like -C forbids the characters outside the ASCII range that match -characters inside that range from matching under C. This did not -work under some circumstances, all involving alternation, such as: - - "\N{KELVIN SIGN}" =~ /k|foo/iaa; - -succeeded inappropriately. This is now fixed. +Deleting the current hash iterator (the hash element that would be returend +by the next call to C) in void context used not to free it +[perl #85026]. =item * -5.14.0 introduced some memory leaks in regular expression character -classes such as C<[\w\s]>, which have now been fixed. (5.14.1) +Deletion of methods via C syntax used to update +method caches if called in void context, but not scalar or list context. =item * -An edge case in regular expression matching could potentially loop. -This happened only under C in bracketed character classes that have -characters with multi-character folds, and the target string to match -against includes the first portion of the fold, followed by another -character that has a multi-character fold that begins with the remaining -portion of the fold, plus some more. - - "s\N{U+DF}" =~ /[\x{DF}foo]/i - -is one such case. C<\xDF> folds to C<"ss">. (5.14.1) +When hash elements are deleted in void context, the internal hash entry is +now freed before the value is freed, to prevent destructors called by that +latter freeing from seeing the hash in an inconsistent state. It was +possible to cause double-frees if the destructor freed the hash itself +[perl #100340]. =item * -A few characters in regular expression pattern matches did not -match correctly in some circumstances, all involving C. The -affected characters are: -COMBINING GREEK YPOGEGRAMMENI, -GREEK CAPITAL LETTER IOTA, -GREEK CAPITAL LETTER UPSILON, -GREEK PROSGEGRAMMENI, -GREEK SMALL LETTER IOTA WITH DIALYTIKA AND OXIA, -GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS, -GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND OXIA, -GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS, -LATIN SMALL LETTER LONG S, -LATIN SMALL LIGATURE LONG S T, -and -LATIN SMALL LIGATURE ST. +A C optimisation in Perl 5.12.0 to make it faster on empty hashes +caused C not to reset the iterator if called after the last element +was deleted. =item * -A memory leak regression in regular expression compilation -under threading has been fixed. +Freeing deeply nested hashes no longer crashes [perl #44225]. =item * -A regression introduced in 5.13.6 has -been fixed. This involved an inverted -bracketed character class in a regular expression that consisted solely -of a Unicode property. That property wasn't getting inverted outside the -Latin1 range. +It is possible from XS code to create hashes with elements that have no +values. The hash element and slice operators used to crash +when handling these in lvalue context. They now +produce a "Modification of non-creatable hash value attempted" error +message. =item * -Three problematic Unicode characters now work better in regex pattern matching under C - -In the past, three Unicode characters: -LATIN SMALL LETTER SHARP S, -GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS, -and -GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS, -along with the sequences that they fold to -(including "ss" in the case of LATIN SMALL LETTER SHARP S), -did not properly match under C. 5.14.0 fixed some of these cases, -but introduced others, including a panic when one of the characters or -sequences was used in the C<(?(DEFINE)> regular expression predicate. -The known bugs that were introduced in 5.14 have now been fixed; as well -as some other edge cases that have never worked until now. All these -involve using the characters and sequences outside bracketed character -classes under C. This closes [perl #98546]. - -There remain known problems when using certain characters with -multi-character folds inside bracketed character classes, including such -constructs as C. These -remaining bugs are addressed in [perl #89774]. +If list assignment to a hash or array triggered destructors that freed the +hash or array itself, a crash would ensue. This is no longer the case +[perl #107440]. =item * -RT #78266: The regex engine has been leaking memory when accessing -named captures that weren't matched as part of a regex ever since 5.10 -when they were introduced, e.g. this would consume over a hundred MB of -memory: - - for (1..10_000_000) { - if ("foo" =~ /(foo|(?bar))?/) { - my $capture = $+{capture} - } - } - system "ps -o rss $$"' +It used to be possible to free the typeglob of a localised array or hash +(e.g., C), resulting in a crash on scope exit. =item * -In 5.14, C and C no longer matched the -opposite case. This has been fixed [perl #101970]. - -=item * +Some core bugs affecting L have been fixed: locking a hash +element that is a glob copy no longer causes subsequent assignment to it to +corrupt the glob, and unlocking a hash element that holds a copy-on-write +scalar no longer causes modifications to that scalar to modify other +scalars that were sharing the same string buffer. -A regular expression match with an overloaded object on the right-hand side -would in some cases stringify the object too many times. +=back -=item * +=head2 C API fixes -A regression has been fixed that was introduced in 5.14, in C -regular expression matching, in which a match improperly fails if the -pattern is in UTF-8, the target string is not, and a Latin-1 character -precedes a character in the string that should match the pattern. -[perl #101710] +=over =item * -In case-insensitive regular expression pattern matching, no longer on -UTF-8 encoded strings does the scan for the start of match only look at -the first possible position. This caused matches such as -C<"f\x{FB00}" =~ /ff/i> to fail. +The C XS function now works on tied hashes, instead of crashing or +returning an empty hash. =item * -The regexp optimiser no longer crashes on debugging builds when merging -fixed-string nodes with inconvenient contents. +The C C macro now returns false for read-only copies of typeglobs, +such as those created by: -=item * + $hash{elem} = *foo; + Hash::Util::lock_value %hash, 'elem'; -A panic involving the combination of the regular expression modifiers -C and the C<\b> escape sequence introduced in 5.14.0 has been -fixed [perl #95964]. +It used to return true. =item * -The combination of the regular expression modifiers C and the C<\b> -and C<\B> escape sequences did not work properly on UTF-8 encoded -strings. All non-ASCII characters under C should be treated as -non-word characters, but what was happening was that Unicode rules were -used to determine wordness/non-wordness for non-ASCII characters. This -is now fixed [perl #95968]. +The C C function no longer tries to modify its argument, +resulting in errors [perl #108994]. =item * -C<< (?foo: ...) >> no longer loses passed in character set. +C now works properly with magical variables. =item * -The trie optimisation used to have problems with alternations containing -an empty C<(?:)>, causing C<< "x" =~ /\A(?>(?:(?:)A|B|C?x))\z/ >> not to -match, whereas it should [perl #111842]. +C now works properly non-PVs. =item * -Use of lexical (C) variables in code blocks embedded in regular -expressions will no longer result in memory corruption or crashes. - -Nevertheless, these code blocks are still experimental, as there are still -problems with the wrong variables being closed over (in loops for instance) -and with abnormal exiting (e.g., C) causing memory corruption. +When presented with malformed UTF-8 input, the XS-callable functions +C, C, and +C could read beyond the end of the input +string by up to 12 bytes. This no longer happens. [perl #32080]. +However, currently, C still has this defect, see +L above. =item * -The C<\h>, C<\H>, C<\v> and C<\V> regular expression metacharacters used to -cause a panic error message when attempting to match at the end of the -string [perl #96354]. - -=item * +The C-level C function could become confused as to whether the +pattern was in UTF8 if the pattern was an overloaded, tied, or otherwise +magical scalar [perl #101940]. -The abbreviations for four C1 control characters C C, C, and -C were previously unrecognized by C<\N{}>, vianame(), and -string_vianame(). +=back -=item * +=head2 Compile-time hints -Mentioning a variable named "&" other than C<$&> (i.e., C<@&> or C<%&>) no -longer stops C<$&> from working. The same applies to variables named "'" -and "`" [perl #24237]. +=over =item * -Creating a C sub no longer stops C<%+>, C<%-> and -C<%!> from working some of the time [perl #105024]. - -=back - -=head2 Formats - -=over +Tying C<%^H> no longer causes perl to crash or ignore the contents of +C<%^H> when entering a compilation scope [perl #106282]. =item * -A number of edge cases have been fixed with formats and C; -in particular, where the format itself is potentially variable (such as -with ties and overloading), and where the format and data differ in their -encoding. In both these cases, it used to possible for the output to be -corrupted [perl #91032]. +C and C used not to +localise C<%^H> during compilation if it +was empty at the time the C call itself was compiled. This could +lead to scary side effects, like C enabling other flags that +the surrounding code was trying to enable for its caller [perl #68750]. =item * -C no longer converts its argument into a string in-place. So -passing a reference to C no longer destroys the reference -[perl #79532]. +C and C no longer localise hints (C<$^H> and C<%^H>) +at run time, but only during compilation of the $string or required file. +This makes C equivalent to +C [perl #70151]. =item * -Assignment to C<$^A> (the format output accumulator) now recalculates -the number of lines output. +Creating a BEGIN block from XS code (via C or C) would, +on completion, make the hints of the current compiling code the current +hints. This could cause warnings to occur in a non-warning scope. =back @@ -2014,1042 +1920,1154 @@ See L, above. =back -=head2 Lvalue subroutines +=head2 The debugger =over =item * -Explicit return now returns the actual argument passed to return, instead -of copying it [perl #72724, #72706]. +F, and consequently the C command in the debugger, have been +fixed to handle objects blessed into classes whose names contain "=". The +contents of such objects used not to be dumped [perl #101814]. =item * -Lvalue subroutines used to enforce lvalue syntax (i.e., whatever can go on -the left-hand side of C<=>) for the last statement and the arguments to -return. Since lvalue subroutines are not always called in lvalue context, -this restriction has been lifted. +The "R" command for restarting a debugger session has been fixed to work on +Windows, or any other system lacking a C constant +[perl #87740]. =item * -Lvalue subroutines are less restrictive as to what values can be returned. -It used to croak on values returned by C and C and from -other subroutines, but no longer does so [perl #71172]. +The C<#line 42 foo> directive used not to update the arrays of lines used +by the debugger if it occurred in a string eval. This was partially fixed +in 5.14, but it only worked for a single C<#line 42 foo> in each eval. Now +it works for multiple. =item * -Empty lvalue subroutines (C) used to return C<@_> in list -context. In fact, all subroutines used to, but regular subs were fixed in -Perl 5.8.2. Now lvalue subroutines have been likewise fixed. +When subroutine calls are intercepted by the debugger, the name of the +subroutine or a reference to it is stored in C<$DB::sub>, for the debugger +to access. In some cases (such as C<$foo = *bar; undef *bar; &$foo>) +C<$DB::sub> would be set to a name that could not be used to find the +subroutine, and so the debugger's attempt to call it would fail. Now the +check to see whether a reference is needed is more robust, so those +problems should not happen anymore [rt.cpan.org #69862]. =item * -Autovivification now works on values returned from lvalue subroutines -[perl #7946], as does returning C in lvalue context. - -=item * +Every subroutine has a filename associated with it that the debugger uses. +The one associated with constant subroutines used to be misallocated when +cloned under threads. Consequently, debugging threaded applications could +result in memory corruption [perl #96126]. -Lvalue subroutines used to copy their return values in rvalue context. Not -only was this a waste of CPU cycles, but it also caused bugs. A C<($)> -prototype would cause an lvalue sub to copy its return value [perl #51408], -and C would loop endlessly -[perl #78680]. +=back -=item * +=head2 Dereferencing operators -When called in potential lvalue context -(e.g., subroutine arguments or a list -passed to C), lvalue subroutines used to copy -any read-only value that was returned. E.g., C< sub :lvalue { $] } > -would not return C<$]>, but a copy of it. +=over =item * -When called in potential lvalue context, an lvalue subroutine returning -arrays or hashes used to bind the arrays or hashes to scalar variables, -resulting in bugs. This was fixed in 5.14.0 if an array were the first -thing returned from the subroutine (but not for C<$scalar, @array> or -hashes being returned). Now a more general fix has been applied -[perl #23790]. +C, C, etc., used to +return true for most, but not all built-in variables, if +they had not been used yet. This bug affected C<${^GLOBAL_PHASE}> and +C<${^UTF8CACHE}>, among others. It also used to return false if the +package name was given as well (C<${"::!"}>) [perl #97978, #97492]. =item * -Method calls whose arguments were all surrounded with C or C -(as in C<< $object->method(my($a,$b)) >>) used to force lvalue context on -the subroutine. This would prevent lvalue methods from returning certain -values. +Perl 5.10.0 introduced a similar bug: C where "foo" +represents the name of a built-in global variable used to return false if +the variable had never been used before, but only on the I call. +This, too, has been fixed. =item * -Lvalue sub calls that are not determined to be such at compile time -(C<&$name> or &{"name"}) are no longer exempt from strict refs if they -occur in the last statement of an lvalue subroutine [perl #102486]. - -=item * +Since 5.6.0, C<*{ ... }> has been inconsistent in how it treats undefined +values. It would die in strict mode or lvalue context for most undefined +values, but would be treated as the empty string (with a warning) for the +specific scalar return by C (C<&PL_sv_undef> internally). This +has been corrected. C is now treated like other undefined +scalars, as in Perl 5.005. -Sub calls whose subs are not visible at compile time, if -they occurred in the last statement of an lvalue subroutine, -would reject non-lvalue subroutines and die with "Can't modify non-lvalue -subroutine call" [perl #102486]. +=back -Non-lvalue sub calls whose subs I visible at compile time exhibited -the opposite bug. If the call occurred in the last statement of an lvalue -subroutine, there would be no error when the lvalue sub was called in -lvalue context. Perl would blindly assign to the temporary value returned -by the non-lvalue subroutine. +=head2 Filehandle, last-accessed -=item * +Perl has an internal variable that stores the last filehandle to be +accessed. It is used by C<$.> and by C and C without +arguments. -C routines used to take precedence over the actual sub being -called (i.e., when autoloading wasn't needed), for sub calls in lvalue or -potential lvalue context, if the subroutine was not visible at compile -time. +=over =item * -Applying the C<:lvalue> attribute to an XSUB or to an aliased subroutine -stub with C<< sub foo :lvalue; >> syntax stopped working in Perl 5.12. -This has been fixed. +It used to be possible to set this internal variable to a glob copy and +then modify that glob copy to be something other than a glob, and still +have the last-accessed filehandle associated with the variable after +assigning a glob to it again: -=item * + my $foo = *STDOUT; # $foo is a glob copy + <$foo>; # $foo is now the last-accessed handle + $foo = 3; # no longer a glob + $foo = *STDERR; # still the last-accessed handle -Applying the :lvalue attribute to subroutine that is already defined does -not work properly, as the attribute changes the way the sub is compiled. -Hence, Perl 5.12 began warning when an attempt is made to apply the -attribute to an already defined sub. In such cases, the attribute is -discarded. +Now the C<$foo = 3> assignment unsets that internal variable, so there +is no last-accessed filehandle, just as if C<< <$foo> >> had never +happened. -But the change in 5.12 missed the case where custom attributes are also -present: that case still silently and ineffectively applied the attribute. -That omission has now been corrected. C (when -C is already defined) now warns about the :lvalue attribute, and does -not apply it. +This also prevents some unrelated handle from becoming the last-accessed +handle if $foo falls out of scope and the same internal SV gets used for +another handle [perl #97988]. =item * -A bug affecting lvalue context propagation through nested lvalue subroutine -calls has been fixed. Previously, returning a value in nested rvalue -context would be treated as lvalue context by the inner subroutine call, -resulting in some values (such as read-only values) being rejected. +A regression in 5.14 caused these statements not to set that internal +variable: + + my $fh = *STDOUT; + tell $fh; + eof $fh; + seek $fh, 0,0; + tell *$fh; + eof *$fh; + seek *$fh, 0,0; + readline *$fh; + +This is now fixed, but C still has the problem, and it +is not clear how to fix it [perl #106536]. =back -=head2 Compile-time hints +=head2 Filetests and C + +The term "filetests" refers to the operators that consist of a hyphen +followed by a single letter: C<-r>, C<-x>, C<-M>, etc. The term "stacked" +when applied to filetests means followed by another filetest operator +sharing the same operand, as in C<-r -x -w $fooo>. =over =item * -Tying C<%^H> no longer causes perl to crash or ignore the contents of -C<%^H> when entering a compilation scope [perl #106282]. +C produces more consistent warnings. It no longer warns for "_" +[perl #71002] and no longer skips the warning at times for other unopened +handles. It no longer warns about an unopened handle when the operating +system's C function fails. =item * -C and C used not to -localise C<%^H> during compilation if it -was empty at the time the C call itself was compiled. This could -lead to scary side effects, like C enabling other flags that -the surrounding code was trying to enable for its caller [perl #68750]. +C would sometimes return negative numbers for large inode numbers, +because it was using the wrong internal C type. [perl #84590] =item * -C and C no longer localise hints (C<$^H> and C<%^H>) -at run time, but only during compilation of the $string or required file. -This makes C equivalent to -C [perl #70151]. +C is documented to fall back to C (with a warning) when given +a filehandle. When passed an IO reference, it was actually doing the +equivalent of S> and ignoring the handle. =item * -Creating a BEGIN block from XS code (via C or C) would, -on completion, make the hints of the current compiling code the current -hints. This could cause warnings to occur in a non-warning scope. - -=back +C<-T _> with no preceding C used to produce a +confusing "uninitialized" warning, even though there +is no visible uninitialized value to speak of. -=head2 Fixes related to hashes and arrays +=item * -=over +C<-T>, C<-B>, C<-l> and C<-t> now work +when stacked with other filetest operators +[perl #77388]. =item * -A bug has been fixed that would cause a "Use of freed value in iteration" -error if the next two hash elements that would be iterated over are -deleted [perl #85026]. (5.14.1) +In 5.14.0, filetest ops (C<-r>, C<-x>, etc.) started calling FETCH on a +tied argument belonging to the previous argument to a list operator, if +called with a bareword argument or no argument at all. This has been +fixed, so C no longer calls FETCH on C<$tied>. =item * -Deleting the current hash iterator (the hash element that would be returend -by the next call to C) in void context used not to free it -[perl #85026]. +In Perl 5.6, C<-l> followed by anything other than a bareword would treat +its argument as a file name. That was changed in 5.8 for glob references +(C<\*foo>), but not for globs themselves (C<*foo>). C<-l> started +returning C for glob references without setting the last +stat buffer that the "_" handle uses, but only if warnings +were turned on. With warnings off, it was the same as 5.6. +In other words, it was simply buggy and inconsistent. Now the 5.6 +behaviour has been restored. =item * -Deletion of methods via C syntax used to update -method caches if called in void context, but not scalar or list context. +C<-l> followed by a bareword no longer "eats" the previous argument to +the list operator in whose argument list it resides. Hence, +C now actually prints "bar", because C<-l> +on longer eats it. =item * -When hash elements are deleted in void context, the internal hash entry is -now freed before the value is freed, to prevent destructors called by that -latter freeing from seeing the hash in an inconsistent state. It was -possible to cause double-frees if the destructor freed the hash itself -[perl #100340]. +Perl keeps several internal variables to keep track of the last stat +buffer, from which file(handle) it originated, what type it was, and +whether the last stat succeeded. + +There were various cases where these could get out of synch, resulting in +inconsistent or erratic behaviour in edge cases (every mention of C<-T> +applies to C<-B> as well): + +=over =item * -A C optimisation in Perl 5.12.0 to make it faster on empty hashes -caused C not to reset the iterator if called after the last element -was deleted. +C<-T I>, even though it does a C, was not resetting the last +stat type, so an C following it would merrily return the wrong +results. Also, it was not setting the success status. =item * -Freeing deeply nested hashes no longer crashes [perl #44225]. +Freeing the handle last used by C or a filetest could result in +S> using an unrelated handle. =item * -It is possible from XS code to create hashes with elements that have no -values. The hash element and slice operators used to crash -when handling these in lvalue context. They now -produce a "Modification of non-creatable hash value attempted" error -message. +C with an IO reference would not reset the stat type or record the +filehandle for S> to use. =item * -If list assignment to a hash or array triggered destructors that freed the -hash or array itself, a crash would ensue. This is no longer the case -[perl #107440]. +Fatal warnings could cause the stat buffer not to be reset +for a filetest operator on an unopened filehandle or C<-l> on any handle. +Fatal warnings also stopped C<-T> from setting C<$!>. =item * -It used to be possible to free the typeglob of a localised array or hash -(e.g., C), resulting in a crash on scope exit. +When the last stat was on an unreadable file, C<-T _> is supposed to +return C, leaving the last stat buffer unchanged. But it was +setting the stat type, causing C to stop working. =item * -Some core bugs affecting L have been fixed: locking a hash -element that is a glob copy no longer causes subsequent assignment to it to -corrupt the glob, and unlocking a hash element that holds a copy-on-write -scalar no longer causes modifications to that scalar to modify other -scalars that were sharing the same string buffer. +C<-T I> was not resetting the internal stat buffers for +unreadable files. =back -=head2 Weak references +These have all been fixed. + +=back + +=head2 Formats =over =item * -Weakening the first argument to an automatically-invoked C method -could result in erroneous "DESTROY created new reference" errors or -crashes. Now it is an error to weaken a read-only reference. +A number of edge cases have been fixed with formats and C; +in particular, where the format itself is potentially variable (such as +with ties and overloading), and where the format and data differ in their +encoding. In both these cases, it used to possible for the output to be +corrupted [perl #91032]. =item * -Weak references to lexical hashes going out of scope were not going stale -(becoming undefined), but continued to point to the hash. +C no longer converts its argument into a string in-place. So +passing a reference to C no longer destroys the reference +[perl #79532]. =item * -Weak references to lexical variables going out of scope are now broken -before any magical methods (e.g., DESTROY on a tie object) are called. -This prevents such methods from modifying the variable that will be seen -the next time the scope is entered. +Assignment to C<$^A> (the format output accumulator) now recalculates +the number of lines output. + +=back + +=head2 C and C + +=over =item * -Creating a weak reference to an @ISA array or accessing the array index -(C<$#ISA>) could result in confused internal bookkeeping for elements -subsequently added to the @ISA array. For instance, creating a weak -reference to the element itself could push that weak reference on to @ISA; -and elements added after use of C<$#ISA> would be ignored by method lookup -[perl #85670]. +C was not scoping its implicit $_ properly, resulting in memory +leaks or "Variable is not available" warnings [perl #94682]. -=back +=item * -=head2 Support for embedded nulls +C was not calling set-magic on the implicit lexical C<$_> that it +uses. This meant, for example, that C would be remembered from one +execution of the same C block to the next, even if the input were a +different variable [perl #84526]. -Some parts of Perl did not work correctly with nulls (C) embedded in -strings. That meant that, for instance, C<< $m = "a\0b"; foo->$m >> would -call the "a" method, instead of the actual method name contained in $m. -These parts of perl have been fixed to support nulls: +=item * + +C blocks are now capable of returning variables declared inside the +enclosing C block [perl #93548]. + +=back + +=head2 The C operator =over =item * -Method names +On OSes other than VMS, Perl's C operator (and the C<< <...> >> form) +use L underneath. L splits the pattern into words, +before feeding each word to its C function. + +There were several inconsistencies in the way the split was done. Now +quotation marks (' and ") are always treated as shell-style word delimiters +(that allow whitespace as part of a word) and backslashes are always +preserved, unless they exist to escape quotation marks. Before, those +would only sometimes be the case, depending on whether the pattern +contained whitespace. Also, escaped whitespace at the end of the pattern +is no longer stripped [perl #40470]. =item * -Typeglob names (including filehandle and subroutine names) +C now works as a way to call the default globbing function. It +used to respect overrides, despite the C prefix. =item * -Package names, including the return value of C +Under miniperl (used to configure modules when perl itself is built), +C now clears %ENV before calling csh, since the latter croaks on some +systems if it does not like the contents of the LS_COLORS enviroment +variable [perl #98662]. + +=back + +=head2 Lvalue subroutines + +=over =item * -Typeglob elements (C<*foo{"THING\0stuff"}>) +Explicit return now returns the actual argument passed to return, instead +of copying it [perl #72724, #72706]. =item * -Signal names +Lvalue subroutines used to enforce lvalue syntax (i.e., whatever can go on +the left-hand side of C<=>) for the last statement and the arguments to +return. Since lvalue subroutines are not always called in lvalue context, +this restriction has been lifted. =item * -Various warnings and error messages that mention variable names or values, -methods, etc. +Lvalue subroutines are less restrictive as to what values can be returned. +It used to croak on values returned by C and C and from +other subroutines, but no longer does so [perl #71172]. -=back +=item * -One side effect of these changes is that blessing into "\0" no longer -causes C to return false. +Empty lvalue subroutines (C) used to return C<@_> in list +context. In fact, all subroutines used to, but regular subs were fixed in +Perl 5.8.2. Now lvalue subroutines have been likewise fixed. -=head2 Filetests and C +=item * -The term "filetests" refers to the operators that consist of a hyphen -followed by a single letter: C<-r>, C<-x>, C<-M>, etc. The term "stacked" -when applied to filetests means followed by another filetest operator -sharing the same operand, as in C<-r -x -w $fooo>. +Autovivification now works on values returned from lvalue subroutines +[perl #7946], as does returning C in lvalue context. -=over +=item * + +Lvalue subroutines used to copy their return values in rvalue context. Not +only was this a waste of CPU cycles, but it also caused bugs. A C<($)> +prototype would cause an lvalue sub to copy its return value [perl #51408], +and C would loop endlessly +[perl #78680]. =item * -C produces more consistent warnings. It no longer warns for "_" -[perl #71002] and no longer skips the warning at times for other unopened -handles. It no longer warns about an unopened handle when the operating -system's C function fails. +When called in potential lvalue context +(e.g., subroutine arguments or a list +passed to C), lvalue subroutines used to copy +any read-only value that was returned. E.g., C< sub :lvalue { $] } > +would not return C<$]>, but a copy of it. =item * -C would sometimes return negative numbers for large inode numbers, -because it was using the wrong internal C type. [perl #84590] +When called in potential lvalue context, an lvalue subroutine returning +arrays or hashes used to bind the arrays or hashes to scalar variables, +resulting in bugs. This was fixed in 5.14.0 if an array were the first +thing returned from the subroutine (but not for C<$scalar, @array> or +hashes being returned). Now a more general fix has been applied +[perl #23790]. =item * -C is documented to fall back to C (with a warning) when given -a filehandle. When passed an IO reference, it was actually doing the -equivalent of S> and ignoring the handle. +Method calls whose arguments were all surrounded with C or C +(as in C<< $object->method(my($a,$b)) >>) used to force lvalue context on +the subroutine. This would prevent lvalue methods from returning certain +values. =item * -C<-T _> with no preceding C used to produce a -confusing "uninitialized" warning, even though there -is no visible uninitialized value to speak of. +Lvalue sub calls that are not determined to be such at compile time +(C<&$name> or &{"name"}) are no longer exempt from strict refs if they +occur in the last statement of an lvalue subroutine [perl #102486]. =item * -C<-T>, C<-B>, C<-l> and C<-t> now work -when stacked with other filetest operators -[perl #77388]. +Sub calls whose subs are not visible at compile time, if +they occurred in the last statement of an lvalue subroutine, +would reject non-lvalue subroutines and die with "Can't modify non-lvalue +subroutine call" [perl #102486]. + +Non-lvalue sub calls whose subs I visible at compile time exhibited +the opposite bug. If the call occurred in the last statement of an lvalue +subroutine, there would be no error when the lvalue sub was called in +lvalue context. Perl would blindly assign to the temporary value returned +by the non-lvalue subroutine. =item * -In 5.14.0, filetest ops (C<-r>, C<-x>, etc.) started calling FETCH on a -tied argument belonging to the previous argument to a list operator, if -called with a bareword argument or no argument at all. This has been -fixed, so C no longer calls FETCH on C<$tied>. +C routines used to take precedence over the actual sub being +called (i.e., when autoloading wasn't needed), for sub calls in lvalue or +potential lvalue context, if the subroutine was not visible at compile +time. =item * -In Perl 5.6, C<-l> followed by anything other than a bareword would treat -its argument as a file name. That was changed in 5.8 for glob references -(C<\*foo>), but not for globs themselves (C<*foo>). C<-l> started -returning C for glob references without setting the last -stat buffer that the "_" handle uses, but only if warnings -were turned on. With warnings off, it was the same as 5.6. -In other words, it was simply buggy and inconsistent. Now the 5.6 -behaviour has been restored. +Applying the C<:lvalue> attribute to an XSUB or to an aliased subroutine +stub with C<< sub foo :lvalue; >> syntax stopped working in Perl 5.12. +This has been fixed. =item * -C<-l> followed by a bareword no longer "eats" the previous argument to -the list operator in whose argument list it resides. Hence, -C now actually prints "bar", because C<-l> -on longer eats it. +Applying the :lvalue attribute to subroutine that is already defined does +not work properly, as the attribute changes the way the sub is compiled. +Hence, Perl 5.12 began warning when an attempt is made to apply the +attribute to an already defined sub. In such cases, the attribute is +discarded. + +But the change in 5.12 missed the case where custom attributes are also +present: that case still silently and ineffectively applied the attribute. +That omission has now been corrected. C (when +C is already defined) now warns about the :lvalue attribute, and does +not apply it. =item * -Perl keeps several internal variables to keep track of the last stat -buffer, from which file(handle) it originated, what type it was, and -whether the last stat succeeded. +A bug affecting lvalue context propagation through nested lvalue subroutine +calls has been fixed. Previously, returning a value in nested rvalue +context would be treated as lvalue context by the inner subroutine call, +resulting in some values (such as read-only values) being rejected. -There were various cases where these could get out of synch, resulting in -inconsistent or erratic behaviour in edge cases (every mention of C<-T> -applies to C<-B> as well): +=back + +=head2 Overloading =over =item * -C<-T I>, even though it does a C, was not resetting the last -stat type, so an C following it would merrily return the wrong -results. Also, it was not setting the success status. +Arithmetic assignment (C<$left += $right>) involving overloaded objects +that rely on the 'nomethod' override no longer segfault when the left +operand is not overloaded. =item * -Freeing the handle last used by C or a filetest could result in -S> using an unrelated handle. +Errors that occur when methods cannot be found during overloading now +mention the correct package name, as they did in 5.8.x, instead of +erroneously mentioning the "overload" package, as they have since 5.10.0. =item * -C with an IO reference would not reset the stat type or record the -filehandle for S> to use. +Undefining C<%overload::> no longer causes a crash. -=item * +=back -Fatal warnings could cause the stat buffer not to be reset -for a filetest operator on an unopened filehandle or C<-l> on any handle. -Fatal warnings also stopped C<-T> from setting C<$!>. +=head2 Prototypes of built-in keywords + +=over =item * -When the last stat was on an unreadable file, C<-T _> is supposed to -return C, leaving the last stat buffer unchanged. But it was -setting the stat type, causing C to stop working. +The C function no longer dies for the C<__FILE__>, C<__LINE__> +and C<__PACKAGE__> directives. It now returns an empty-string prototype +for them, because they are syntactically indistinguishable from nullary +functions like C