summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-30 12:42:41 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-30 12:42:41 +0000
commit458d36fbe53eee3cef72fd8495e97d35273d1614 (patch)
tree04e50575965b636ca630915d6b87914b4db5a4c5
parent458c447fdfbacfc5f8b3da40f103ca2bf8eb6ca2 (diff)
downloadruby-458d36fbe53eee3cef72fd8495e97d35273d1614.tar.gz
ruby-458d36fbe53eee3cef72fd8495e97d35273d1614.tar.xz
ruby-458d36fbe53eee3cef72fd8495e97d35273d1614.zip
* compile.c (iseq_compile_each): fix stack consistency error.
[ruby-core:24611] * bootstraptest/test_method.rb: add tests for above. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@24323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--bootstraptest/test_method.rb10
-rw-r--r--compile.c8
3 files changed, 19 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 42128554c..f9cbacf27 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Thu Jul 30 21:39:42 2009 Yusuke Endoh <mame@tsg.ne.jp>
+
+ * compile.c (iseq_compile_each): fix stack consistency error.
+ [ruby-core:24611]
+
+ * bootstraptest/test_method.rb: add tests for above.
+
Thu Jul 30 18:39:39 2009 Martin Duerst <duerst@it.aoyama.ac.jp>
* transcode.c: added check for frozen string for encode! (see Bug #1836)
diff --git a/bootstraptest/test_method.rb b/bootstraptest/test_method.rb
index 8953a0d4d..2ce66f6a6 100644
--- a/bootstraptest/test_method.rb
+++ b/bootstraptest/test_method.rb
@@ -1151,3 +1151,13 @@ assert_normal_exit %q{
e.message == "undefined method `lalala!' for \"a\":String" ? :ok : :ng
end
}, '[ruby-core:22298]'
+
+assert_equal 'ok', %q{
+ "hello"[0] ||= "H"
+ "ok"
+}
+
+assert_equal 'ok', %q{
+ "hello"[0, 1] ||= "H"
+ "ok"
+}
diff --git a/compile.c b/compile.c
index c3e25dee2..1c5dba523 100644
--- a/compile.c
+++ b/compile.c
@@ -3799,12 +3799,8 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
}
ADD_INSNL(ret, nd_line(node), jump, lfin);
ADD_LABEL(ret, label);
- if (id == 0 || id == 1) { /* 0: or, 1: and */
- ADD_INSN(ret, nd_line(node), swap);
- ADD_INSN(ret, nd_line(node), pop);
- ADD_INSN(ret, nd_line(node), swap);
- ADD_INSN(ret, nd_line(node), pop);
- }
+ ADD_INSN1(ret, nd_line(node), setn, INT2FIX(FIX2INT(argc) + 1));
+ ADD_INSN1(ret, nd_line(node), adjuststack, INT2FIX(FIX2INT(argc) + 1));
ADD_LABEL(ret, lfin);
}
else {