[ruby-core:105815] [Ruby master Bug#18267] Argument forwarding requires parenthesis on method definitions
From:
"Eregon (Benoit Daloze)" <noreply@...>
Date:
2021-10-26 19:08:43 UTC
List:
ruby-core #105815
Issue #18267 has been updated by Eregon (Benoit Daloze). On a more serious note, `def=` also has this restriction: ``` $ ruby -e 'def m(a) = 2' OK $ ruby -e 'def m a = 2' -e:1: syntax error, unexpected end-of-input $ ruby -e 'def m a = a' -e:1: circular argument reference - a -e:1: syntax error, unexpected end-of-input ``` Which I guess is trivially ambiguous because the `=` could be for an optional arg or for the method body. Because `(...)` anyway needs parenthesis on call sites (ambiguous with endless ranges otherwise), I personally think it makes sense to also have parens as a parameter. ---------------------------------------- Bug #18267: Argument forwarding requires parenthesis on method definitions https://bugs.ruby-lang.org/issues/18267#change-94334 * Author: tenderlovemaking (Aaron Patterson) * Status: Open * Priority: Normal * ruby -v: ruby 3.1.0dev (2021-10-21T22:47:38Z master 844588f915) [x86_64-darwin20] * Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- I like to write my method definitions without parenthesis. For example: ```ruby def foo bar # ... end ``` I tried to use `...`, but it doesn't work. For example if I do: ```ruby def call a, ... a.nil?(...) end ``` It will be a syntax error, and the program exits. Can we make this syntax work so that I can always omit parenthesis? Thank you! -- 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>