Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enumerator containing range does not pass a block variable #2632

Closed
hiukkanen opened this issue Feb 28, 2015 · 3 comments
Closed

Enumerator containing range does not pass a block variable #2632

hiukkanen opened this issue Feb 28, 2015 · 3 comments

Comments

@hiukkanen
Copy link

(1..1).each &method(:puts)

# cruby => 1
# jruby =>
@headius
Copy link
Member

headius commented Mar 12, 2015

Looks like it's not turning it into a proc that receives one argument, and it's just putsing the newline.

@headius
Copy link
Member

headius commented Mar 12, 2015

A test with an intermediate method shows it's passing nil out for some reason. Going to debug.

@headius
Copy link
Member

headius commented Mar 12, 2015

So the problem was an optimization we made to Range#each many years ago, where it checks if the target block actually wants arguments before it creates and passes them. However the logic for turning a method into a proc was always setting up that proc to report that it takes no block arguments.

Fix coming for 1.7 and 9k.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants