diff options
author | David Mitchell <davem@iabyn.com> | 2010-01-12 00:14:41 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2010-01-12 00:26:59 +0000 |
commit | 1809c940bf4737dd262fc0c026e063316c466a28 (patch) | |
tree | 5f96ecc22b872c5f31e662bccc2de73d88cb1821 /t | |
parent | 0097b436152452e403cc71b4f1a1cfd30ec0ba1a (diff) | |
download | perl-1809c940bf4737dd262fc0c026e063316c466a28.tar.gz |
fix for [perl #65582] anon globs segfaulting
The following code has had differing behaviours:
my $io_ref = *STDOUT{IO};
my $glob = *$io_ref;
defined($glob) "$glob"
-------------- -------
5.8.8 false "" with uninit warning
5.10.0 true (coredump)
this commit true ""
$glob is essentially an anonymous typeglob (no NAME, EGV or GvSTASH).
It shouldn't register as undefined since it's clearly a valid GV with a
valid IO slot; Stringifying to "" seems to be the right thing, and not
warning seems right too, since its not undef.
Diffstat (limited to 't')
-rw-r--r-- | t/op/gv.t | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -12,7 +12,7 @@ BEGIN { use warnings; require './test.pl'; -plan( tests => 178 ); +plan( tests => 181 ); # type coersion on assignment $foo = 'foo'; @@ -560,6 +560,27 @@ foreach my $type (qw(integer number string)) { "with the correct error message"); } +# RT #60954 anonymous glob should be defined, and not coredump when +# stringified. The behaviours are: +# +# defined($glob) "$glob" +# 5.8.8 false "" with uninit warning +# 5.10.0 true (coredump) +# 5.12.0 true "" + +{ + my $io_ref = *STDOUT{IO}; + my $glob = *$io_ref; + ok(defined $glob, "RT #60954 anon glob should be defined"); + + my $warn = ''; + local $SIG{__WARN__} = sub { $warn = $_[0] }; + use warnings; + my $str = "$glob"; + is($warn, '', "RT #60954 anon glob stringification shouln't warn"); + is($str, '', "RT #60954 anon glob stringification should be empty"); +} + __END__ Perl Rules |