summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-19 10:48:17 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-19 10:48:17 +0000
commit59af57e2571fbb361e425783324c6ec38670477e (patch)
tree2b50c331649075b8bfadbf364f8d00dc7ed4a89b
parent7eb7f063a4ff88ca08e2abe0d2f190cec50107dc (diff)
* iseq_compile_each (NODE_DEFINED): put nil first to fix stack
consistency. [ruby-core:30293] Now, lfinish[0] of defined_expr seems not to be used. Refactoring may be needed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--bootstraptest/test_syntax.rb10
-rw-r--r--compile.c5
3 files changed, 20 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 847c595..9f7cf26 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed May 19 19:45:10 2010 Yusuke Endoh <mame@tsg.ne.jp>
+
+ * iseq_compile_each (NODE_DEFINED): put nil first to fix stack
+ consistency. [ruby-core:30293]
+ Now, lfinish[0] of defined_expr seems not to be used. Refactoring
+ may be needed.
+
Wed May 19 16:55:09 2010 NARUSE, Yui <naruse@ruby-lang.org>
* numeric.c (rb_num2ulong): use rb_big2ulong for data from
diff --git a/bootstraptest/test_syntax.rb b/bootstraptest/test_syntax.rb
index 44db11b..ae14883 100644
--- a/bootstraptest/test_syntax.rb
+++ b/bootstraptest/test_syntax.rb
@@ -890,3 +890,13 @@ assert_valid_syntax('x y { "#{}".z { } }', bug1240)
assert_valid_syntax('x y { "#{}".z do end }', bug1240)
assert_valid_syntax('y "#{a 1}" do end', '[ruby-core:29579]')
+assert_normal_exit %q{
+ def foo(&block)
+ yield
+ end
+
+ foo do
+ s = defined?(raise + 1)
+ Class
+ end
+}, '[ruby-core:30293]'
diff --git a/compile.c b/compile.c
index ff1bb23..b030022 100644
--- a/compile.c
+++ b/compile.c
@@ -4815,11 +4815,12 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
LABEL *lfinish[2];
lfinish[0] = NEW_LABEL(nd_line(node));
lfinish[1] = 0;
+ ADD_INSN(ret, nd_line(node), putnil);
defined_expr(iseq, ret, node->nd_head, lfinish, Qtrue);
+ ADD_INSN(ret, nd_line(node), swap);
+ ADD_INSN(ret, nd_line(node), pop);
if (lfinish[1]) {
- ADD_INSNL(ret, nd_line(node), jump, lfinish[0]);
ADD_LABEL(ret, lfinish[1]);
- ADD_INSN(ret, nd_line(node), putnil);
}
ADD_LABEL(ret, lfinish[0]);
}