List Info

Thread: Autovivification and File::Spec




Autovivification and File::Spec
user name
2006-12-26 00:28:03
I use a major bundle (about 200 distributions now) as a test
suite for
Perl 5.8.8.  PathTools-3.18 trigger the following bug in
Perl:

  perl -wle "print 10 if exists $E; print 11
for $E; print 12 if exists $E"
  11
  12

This smells as a bug, but I'm cannot be absolutely sure,
since there
is no reliable documentation for Perl...

But THIS definitely looks like a bug:

  perl -wle "sub f {} print 12 if exists $E; f
E; print 12 if exists $E"
  Scalar value E better written as $E at
-e line 1.
  12

(BTW, the warning is just another bug, because of the list
context...)

The bug is not triggered when one uses f $E;
however, it DOES
happen when one uses f E{qw(TMPDIR TMP)}.

============================================================
====

Anyway, this is how this bug triggers the failure of test
suite:
File::Spec::Unix::_tmpdir() is called with $ENV as
an
argument.  Then it does revivify $ENV to an
undefined value,
and the test suite of PathTools-3.18 is smart enough to
detect this...

Any quick fix?

Thanks,
Ilya
Autovivification and File::Spec
user name
2006-12-26 15:59:21
Ilya Zakharevich wrote:
> I use a major bundle (about 200 distributions now) as a
test suite for
> Perl 5.8.8.  PathTools-3.18 trigger the following bug
in Perl:
> 
>   perl -wle "print 10 if exists $E; print
11 for $E; print 12 if exists $E"
>   11
>   12
> 
> This smells as a bug, but I'm cannot be absolutely
sure, since there
> is no reliable documentation for Perl...
> 
> But THIS definitely looks like a bug:
> 
>   perl -wle "sub f {} print 12 if exists
$E; f E; print 12 if exists
$E"
>   Scalar value E better written as $E at
-e line 1.
>   12
> 
> (BTW, the warning is just another bug, because of the
list context...)
> 
> The bug is not triggered when one uses f $E;
however, it DOES
> happen when one uses f E{qw(TMPDIR TMP)}.

Confirmed on 5.8.8 and 5.8.6 on OS X.  I don't have earlier
Perls to try this out with.
Autovivification and File::Spec
user name
2006-12-26 16:16:28
On 26/12/06, Ilya Zakharevich <nospam-abuseilyaz.org> wrote:
> I use a major bundle (about 200 distributions now) as a
test suite for
> Perl 5.8.8.  PathTools-3.18 trigger the following bug
in Perl:
>
>   perl -wle "print 10 if exists $E; print
11 for $E; print 12 if exists $E"
>   11
>   12
>
> This smells as a bug, but I'm cannot be absolutely
sure, since there
> is no reliable documentation for Perl...

That smells like the kind of misfeature that could break
legacy
programs if changed.

> But THIS definitely looks like a bug:
>
>   perl -wle "sub f {} print 12 if exists
$E; f E; print 12 if exists
$E"
>   Scalar value E better written as $E at
-e line 1.
>   12
>
> (BTW, the warning is just another bug, because of the
list context...)

Yes, that was filed under bug id 34771.
Autovivification and File::Spec
user name
2006-12-26 17:46:01
On Dec 26, 2006, at 10:16 AM, Rafael Garcia-Suarez wrote:

> On 26/12/06, Ilya Zakharevich <nospam-abuseilyaz.org> wrote:
>> I use a major bundle (about 200 distributions now)
as a test suite  
>> for
>> Perl 5.8.8.  PathTools-3.18 trigger the following
bug in Perl:
>>
>>   perl -wle "print 10 if exists $E;
print 11 for $E 
>> ; print 12 if exists $E"
>>   11
>>   12
>>
>> This smells as a bug, but I'm cannot be absolutely
sure, since there
>> is no reliable documentation for Perl...
>
> That smells like the kind of misfeature that could
break legacy
> programs if changed.

This is the same issue raised in [perl #40194]. The
following thread  
can be read

http://beta.nntp.perl.org/group/perl.perl5.porters/20
06/08/ 
msg115825.html

Basically sub arguments got special cased at some point in
time to  
not auto-vivify, but grep, map, for etc were left alone and
so they  
auto-vivify when the element is aliased to $_

Graham.

Autovivification and File::Spec
user name
2006-12-27 08:46:01
On Tue, Dec 26, 2006 at 11:46:01AM -0600, Graham Barr wrote:
> >>This smells as a bug, but I'm cannot be
absolutely sure, since there
> >>is no reliable documentation for Perl...
> >
> >That smells like the kind of misfeature that could
break legacy
> >programs if changed.
> 
> This is the same issue raised in [perl #40194]. The
following thread can be 
> read
> 
> http://beta.nntp.perl.org/group/perl.pe
rl5.porters/2006/08/msg115825.html
> 
> Basically sub arguments got special cased at some point
in time to not 
> auto-vivify, but grep, map, for etc were left alone and
so they auto-vivify 
> when the element is aliased to $_

You did notice that the principal part of this report is
that sub
arguments DO auto-vivify, did not you?

Yours,
Ilya
[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )