aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--bootstraptest/test_syntax.rb8
-rw-r--r--compile.c1
3 files changed, 16 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 9fb98b9625..5500c048bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sat Jan 26 17:42:23 2008 Koichi Sasada <ko1@atdot.net>
+
+ * compile.c (iseq_compile_each): validate argument expr of "next"
+ statement.
+
+ * bootstraptest/test_syntax.rb: add a test.
+
Sat Jan 26 17:22:46 2008 Koichi Sasada <ko1@atdot.net>
* compile.c, compile.h: fix to calculate correct stack depth
diff --git a/bootstraptest/test_syntax.rb b/bootstraptest/test_syntax.rb
index 1c5121cdaa..8a6e622f61 100644
--- a/bootstraptest/test_syntax.rb
+++ b/bootstraptest/test_syntax.rb
@@ -758,3 +758,11 @@ assert_equal 'ok', %q{
end
:ok
}, '[ruby-dev:32882]'
+
+assert_equal "1\n2\n", %q{
+ i = 0
+ while i<2
+ i += 1
+ next p(i)
+ end
+}
diff --git a/compile.c b/compile.c
index 9509af073a..f6545d56d8 100644
--- a/compile.c
+++ b/compile.c
@@ -3044,6 +3044,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
LABEL *splabel = NEW_LABEL(0);
debugs("next in while loop\n");
ADD_LABEL(ret, splabel);
+ COMPILE(ret, "next val/valid syntax?", node->nd_stts);
add_ensure_iseq(ret, iseq);
ADD_ADJUST(ret, nd_line(node), iseq->compile_data->redo_label);
ADD_INSNL(ret, nd_line(node), jump, iseq->compile_data->start_label);