summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Pit <perl@profvince.com>2011-06-27 09:35:57 +0200
committerVincent Pit <perl@profvince.com>2011-06-27 09:35:57 +0200
commit0787ea8aaa88d48f432536f8d8f6658fe8ba47ed (patch)
tree6d5cba9dae5a20114bea77ba2a010a910c9d6431
parentc08f093b3e154c428f604f89f7feb633e6c97869 (diff)
downloadperl-0787ea8aaa88d48f432536f8d8f6658fe8ba47ed.tar.gz
Make sure break() resets the sp at its original level
-rw-r--r--pp_ctl.c4
-rw-r--r--t/op/switch.t16
2 files changed, 18 insertions, 2 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index 9eb281451a..c442d0bf7e 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -5045,7 +5045,9 @@ PP(pp_break)
if (cxix < cxstack_ix)
dounwind(cxix);
- /* RETURNOP calls PUTBACK which restores the old old sp */
+ /* Restore the sp at the time we entered the given block */
+ TOPBLOCK(cx);
+
return cx->blk_givwhen.leave_op;
}
diff --git a/t/op/switch.t b/t/op/switch.t
index 7614630d99..bdf087dd38 100644
--- a/t/op/switch.t
+++ b/t/op/switch.t
@@ -9,7 +9,7 @@ BEGIN {
use strict;
use warnings;
-plan tests => 196;
+plan tests => 197;
# The behaviour of the feature pragma should be tested by lib/feature.t
# using the tests in t/lib/feature/*. This file tests the behaviour of
@@ -1347,6 +1347,20 @@ unreified_check(undef,"");
};
}
+# break() must reset the stack
+{
+ my @res = (1, do {
+ given ("x") {
+ 2, 3, do {
+ when (/[a-z]/) {
+ 4, 5, 6, break
+ }
+ }
+ }
+ });
+ is "@res", "1", "break resets the stack";
+}
+
# Okay, that'll do for now. The intricacies of the smartmatch
# semantics are tested in t/op/smartmatch.t
__END__