Project

General

Profile

Actions

Bug #16169

closed

rescue in a method argument

Added by zverok (Victor Shepelev) over 4 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:94945]

Description

At 2.4, #12686 was introduced, allowing code like this:

foo (Integer(ENV['FOO']) rescue nil)

Though, I noticed that in current Ruby correctness of this syntax depends on space after the method name:

foo (Integer(ENV['FOO']) rescue nil) # => OK

foo(Integer(ENV['FOO']) rescue nil)
# SyntaxError ((irb):4: syntax error, unexpected modifier_rescue, expecting ')')
# foo(Integer(ENV['FOO']) rescue nil)
#                         ^~~~~~

I wonder, whether it is just a bug or a parser limitation (I can't guess which ambiguity the space-less version produces, but I could be missing something)?..

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0