From: shugo@... Date: 2015-12-16T01:42:12+00:00 Subject: [ruby-core:72166] [Ruby trunk - Bug #11811] Chaining lazy enumerators causes duplicate ouput Issue #11811 has been updated by Shugo Maeda. File vm_caller_setup_arg_block.diff added Yusuke Endoh wrote: > So I guess this is caused by nobu's optimization. The bug was introduced in r51995: ``` Author: nobu Date: Thu Oct 1 10:52:52 2015 +0000 vm_args.c: fix marking symbol ifunc * vm_args.c (vm_caller_setup_arg_block): store new ifunc for symbol in control frame proc to be marked. * proc.c (proc_new), vm_insnhelper.c (vm_yield_with_cfunc): block->proc may be an ifunc now. ``` It seems to be fixed by the attached patch, but I'm not sure. Could you check it, nobu? ---------------------------------------- Bug #11811: Chaining lazy enumerators causes duplicate ouput https://bugs.ruby-lang.org/issues/11811#change-55577 * Author: Chris Beer * Status: Open * Priority: Normal * Assignee: Nobuyoshi Nakada * ruby -v: ruby 2.3.0preview2 (2015-12-11 trunk 53028) [x86_64-darwin15] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- In Ruby 2.3.0-preview2, I'm seeing a change in behavior using lazy enumerators with select/reject and the & operator: irb(main):037:0> %w(1 2 3).lazy.reject(&:empty?).each { |x| puts x } 1 1 2 2 3 3 Note that the output is doubled. However, if I don't use the & shorthand, the output is as expected: irb(main):038:0> %w(1 2 3).lazy.reject { |x| x.empty? }.each { |x| puts x } 1 2 3 => nil And in Ruby 2.2.3, both variants produced the same result: irb(main):001:0> %w(1 2 3).lazy.reject(&:empty?).each { |x| puts x } 1 2 3 => nil ---Files-------------------------------- vm_caller_setup_arg_block.diff (1.03 KB) -- https://bugs.ruby-lang.org/