Skip to content

Enumerator using Enumerable method with Symbol#to_proc passing wrong value to yield #7491

@ydah

Description

@ydah

Environment Information

$ jruby -v    
jruby 9.4.0.0 (3.1.0) 2022-11-23 95c0ec159f Java HotSpot(TM) 64-Bit Server VM 25.351-b10 on 1.8.0_351-b10 +jit [x86_64-darwin]

$ uname -a
Darwin 1-2-240.local 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64 x86_64

Expected Behavior

test.rb

p [1].chunk{ true }.map{ |v| v&.last }
p [1].chunk{ true }.map(&:last)

There are no errors with ruby 3.1.2 and jruby 9.3.9.0

$ ruby test.rb
[[1]]
[[1]]

$ jruby test.rb            
[[1]]
[[1]]

Actual Behavior

$ jruby test.rb            
[[1]]
NoMethodError: undefined method `last' for true:TrueClass
   yield at org/jruby/RubyYielder.java:115
      << at org/jruby/RubyYielder.java:120
    each at org/jruby/RubyGenerator.java:98
    each at org/jruby/RubyEnumerator.java:397
     map at org/jruby/RubyEnumerable.java:835
  <main> at test.rb:2
... 7 levels...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions