Skip to content

Rescue in method arguments - #542

Merged
eregon merged 1 commit into
ruby:masterfrom
nicoolas25:rescue-in-method-arguments-bis
Nov 12, 2017
Merged

eregon merged 1 commit into
ruby:masterfrom
nicoolas25:rescue-in-method-arguments-bis

Conversation

@nicoolas25

Copy link
Copy Markdown
Contributor

Follow-up of #509 (comment)

I added a spec for prior Ruby versions that ensure that the syntax isn't supported. I also added the suggested spec regarding the fact that parenthesis must still be around the rescue expression.

I generally don't like testing absence of behavior, which is both those new specs are doing. I'm not sure I would merge something like that... Do you think it is appropriate?

Regarding the call of block and lambdas, this kind of syntax works:

f = ->(a) { 1 + a }
f.call (raise("Error") rescue 1)

After all it is a method call. I'm confused now about what @andrykonchin meant in its comment. If you could tell me more about it here, that would be very appreciated.

@andrykonchin

Copy link
Copy Markdown
Member

you are right, looks like I missed extra white space

There might be another issue with call with []

$ f = ->(a) {puts a}
$ f[1]
1
$ f[1 rescue 0]
SyntaxError: (irb):7: syntax error, unexpected modifier_rescue, expecting ']'
f[1 rescue 0]
          ^

@eregon eregon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, thank you!

@eregon
eregon merged commit e7ac1ca into ruby:master Nov 12, 2017
@nicoolas25
nicoolas25 deleted the rescue-in-method-arguments-bis branch November 13, 2017 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants