Issue #7671 has been reported by phasis68 (Heesob Park). ---------------------------------------- Bug #7671: Unexpected result of the Flip-Flop https://bugs.ruby-lang.org/issues/7671 Author: phasis68 (Heesob Park) Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: ruby 2.0.0dev (2013-01-06 trunk 38715) [i386-mswin32_100] Reported from http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/... C:\work>irb irb(main):001:0> vs = (1..9).to_a => [1, 2, 3, 4, 5, 6, 7, 8, 9] irb(main):002:0> v1 = vs.select { |n| if n==3..n==6 then 1 end } => [3, 4, 5, 6] irb(main):003:0> v2 = vs.select { |n| if n==2..n==16 then 1 end } => [2, 3, 4, 5, 6, 7, 8, 9] irb(main):004:0> v3 = vs.select { |n| if n==3..n==6 then 1 end } => [1, 2, 3, 4, 5, 6] v1 and v3 use some condition , return value is different. This bug is due to changeset r38292 and only occurs on the irb session. Here is a patch: diff --git a/compile.c b/compile.c.new index db060e7..e644390 100644 --- a/compile.c +++ b/compile.c.new @@ -5057,7 +5057,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) if (!data) data = iseq->compile_data; cnt = data->flip_cnt++ + DEFAULT_SPECIAL_VAR_COUNT; - key = INT2FIX(cnt); + key = LL2NUM(cnt+(VALUE)iseq); ADD_INSN2(ret, nd_line(node), getspecial, key, INT2FIX(0)); ADD_INSNL(ret, nd_line(node), branchif, lend);
on 2013-01-07 10:14
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.