Issue #12686 has been updated by Nobuyoshi Nakada.


It sounds nothing wrong with it, to me.

```diff
diff --git i/parse.y w/parse.y
index 17f0f9c..7a14941 100644
--- i/parse.y
+++ w/parse.y
@@ -2659,7 +2659,7 @@ primary		: literal
 			$<val>1 = cmdarg_stack;
 			CMDARG_SET(0);
 		    }
-		  expr {SET_LEX_STATE(EXPR_ENDARG);} rparen
+		  stmt {SET_LEX_STATE(EXPR_ENDARG);} rparen
 		    {
 			CMDARG_SET($<val>1);
 		    /*%%%*/
diff --git i/test/ruby/test_syntax.rb w/test/ruby/test_syntax.rb
index ce01358..9b5b9f1 100644
--- i/test/ruby/test_syntax.rb
+++ w/test/ruby/test_syntax.rb
@@ -827,6 +827,10 @@
     end
   end
 
+  def test_stmt_lparen_arg
+    assert_valid_syntax("foo (bar rescue nil)")
+  end
+
   private
 
   def not_label(x) @result = x; @not_label ||= nil end
```

----------------------------------------
Feature #12686: Allowing a postposed rescue in a method argument
https://bugs.ruby-lang.org/issues/12686#change-60187

* Author: Naotoshi Seo
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
On defining my own DSL, I wanted to write a code like:

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

where `foo` is a method which receives one argument , but I got following error

```
SyntaxError: (irb):1: syntax error, unexpected modifier_rescue, expecting ')'
```

In contrast, following codes were valid:

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

or

```
foo (begin; Integer(ENV['FOO']); rescue; nil; end)
```

This is a feature request to allow such a syntax, a postposed rescue in a method argument.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>