-
Notifications
You must be signed in to change notification settings - Fork 186
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
Enumerable#inject without block causes error #2626
Comments
@eregon This is the spec so far: it "raises a LocalJumpError when no parameters or block is given and self has more than 1 items" do
{}.send(@method).should be_nil
{one: 1}.send(@method).should == [:one, 1]
[].send(@method).should be_nil
[1].send(@method).should == 1
-> { [1,2].send(@method) }.should raise_error(LocalJumpError)
-> { {one: 1, two: 2}.send(@method) }.should raise_error(LocalJumpError)
end |
Indeed, that CRuby behavior is weird, looks like a bug/unintended. It should be ArgumentError or LocalJumpError in all cases. The docs say this:
So I would say let's try to fix the reported issue (i.e. LocalJumpError if no argument & no block) and file a ticket on the CRuby tracker for clarification. |
@eregon I've reported the issue here: https://bugs.ruby-lang.org/issues/18635 |
CRuby has updated this to be an |
Ruby 3.0.2:
[1,2,3].inject # => LocalJumpError
Truffleruby 22.0.0.2:
The text was updated successfully, but these errors were encountered: