From: Vincent Pit Date: Tue, 25 Dec 2007 17:12:33 +0000 (+0100) Subject: Typo in op.c X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=50baa5ea2240b5b5f0f2d876ef7d68fbb74f49e4;p=p5sagit%2Fp5-mst-13.2.git Typo in op.c Message-ID: <47712BF1.9060200@profvince.com> (And then an update to make the tests in gv.t expect the right thing, and test the behaviour that my change 26482 was originally supposed to produce, but didn't until this typo was fixed) p4raw-id: //depot/perl@32779 --- diff --git a/op.c b/op.c index 2185c25..3828894 100644 --- a/op.c +++ b/op.c @@ -8472,7 +8472,7 @@ Perl_peep(pTHX_ register OP *o) UNOP *refgen, *rv2cv; LISTOP *exlist; - if ((o->op_flags && OPf_WANT) != OPf_WANT_VOID) + if ((o->op_flags & OPf_WANT) != OPf_WANT_VOID) break; if ((o->op_private & ~OPpASSIGN_BACKWARDS) != 2) diff --git a/t/op/gv.t b/t/op/gv.t index 2fe0873..e04c2ca 100755 --- a/t/op/gv.t +++ b/t/op/gv.t @@ -12,7 +12,7 @@ BEGIN { use warnings; require './test.pl'; -plan( tests => 167 ); +plan( tests => 178 ); # type coersion on assignment $foo = 'foo'; @@ -377,18 +377,15 @@ is (ref $::{oonk}, 'SCALAR', "Export doesn't affect original"); is (eval 'spritsits', "Value", "Constant has correct value"); is (ref \$::{spritsits}, 'GLOB', "Symbol table has full typeglob"); -my $result; # Check that assignment to an existing typeglob works { my $w = ''; local $SIG{__WARN__} = sub { $w = $_[0] }; - $result = *{"plunk"} = \&{"oonk"}; + *{"plunk"} = []; + *{"plunk"} = \&{"oonk"}; is($w, '', "Should be no warning"); } -is (ref \$result, 'GLOB', - "Non void assignment should still return a typeglob"); - is (ref $::{oonk}, 'SCALAR', "Export doesn't affect original"); is (eval 'plunk', "Value", "Constant has correct value"); is (ref \$::{plunk}, 'GLOB', "Symbol table has full typeglob"); @@ -398,7 +395,7 @@ my $gr = eval '\*plunk' or die; { my $w = ''; local $SIG{__WARN__} = sub { $w = $_[0] }; - $result = *{$gr} = \&{"oonk"}; + *{$gr} = \&{"oonk"}; is($w, '', "Redefining a constant sub to another constant sub with the same underlying value should not warn (It's just re-exporting, and that was always legal)"); } @@ -406,6 +403,48 @@ is (ref $::{oonk}, 'SCALAR', "Export doesn't affect original"); is (eval 'plunk', "Value", "Constant has correct value"); is (ref \$::{plunk}, 'GLOB', "Symbol table has full typeglob"); +# Non-void context should defeat the optimisation, and will cause the original +# to be promoted (what change 26482 intended) +my $result; +{ + my $w = ''; + local $SIG{__WARN__} = sub { $w = $_[0] }; + $result = *{"awkkkkkk"} = \&{"oonk"}; + is($w, '', "Should be no warning"); +} + +is (ref \$result, 'GLOB', + "Non void assignment should still return a typeglob"); + +is (ref \$::{oonk}, 'GLOB', "This export does affect original"); +is (eval 'plunk', "Value", "Constant has correct value"); +is (ref \$::{plunk}, 'GLOB', "Symbol table has full typeglob"); + +delete $::{oonk}; +$::{oonk} = \"Value"; + +sub non_dangling { + my $w = ''; + local $SIG{__WARN__} = sub { $w = $_[0] }; + *{"zap"} = \&{"oonk"}; + is($w, '', "Should be no warning"); +} + +non_dangling(); +is (ref $::{oonk}, 'SCALAR', "Export doesn't affect original"); +is (eval 'zap', "Value", "Constant has correct value"); +is (ref $::{zap}, 'SCALAR', "Exported target is also a PCS"); + +sub dangling { + local $SIG{__WARN__} = sub { die $_[0] }; + *{"biff"} = \&{"oonk"}; +} + +dangling(); +is (ref \$::{oonk}, 'GLOB', "This export does affect original"); +is (eval 'biff', "Value", "Constant has correct value"); +is (ref \$::{biff}, 'GLOB', "Symbol table has full typeglob"); + { use vars qw($glook $smek $foof); # Check reference assignment isn't affected by the SV type (bug #38439)