summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Pit <perl@profvince.com>2007-12-25 18:12:33 +0100
committerNicholas Clark <nick@ccl4.org>2007-12-29 23:00:03 +0000
commit50baa5ea2240b5b5f0f2d876ef7d68fbb74f49e4 (patch)
treebdcf0394efbbebedbddaca85fade2001391d6270
parent50af2e611e4aecf342d3df7e3a9c906c5174ca05 (diff)
downloadperl-50baa5ea2240b5b5f0f2d876ef7d68fbb74f49e4.tar.gz
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
-rw-r--r--op.c2
-rwxr-xr-xt/op/gv.t53
2 files changed, 47 insertions, 8 deletions
diff --git a/op.c b/op.c
index 2185c25938..3828894125 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 2fe0873f01..e04c2cafc8 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)