https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112021-10-26T08:36:34ZRuby Issue Tracking SystemRuby master - Bug #18267: Argument forwarding requires parenthesis on method definitionshttps://bugs.ruby-lang.org/issues/18267?journal_id=943212021-10-26T08:36:34Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul></ul><p>I agree that this is a bug.</p>
<p>Matz.</p> Ruby master - Bug #18267: Argument forwarding requires parenthesis on method definitionshttps://bugs.ruby-lang.org/issues/18267?journal_id=943322021-10-26T18:50:00Zbyroot (Jean Boussier)byroot@ruby-lang.org
<ul></ul><p>It was known when the feature was introduced <a href="https://bugs.ruby-lang.org/projects/ruby-master/repository/git/revisions/d1ae2bc27fd4183e6abb9e83691e192bfe1e5316/diff" class="external">https://bugs.ruby-lang.org/projects/ruby-master/repository/git/revisions/d1ae2bc27fd4183e6abb9e83691e192bfe1e5316/diff</a>, <a class="user active user-mention" href="https://bugs.ruby-lang.org/users/18">@mame (Yusuke Endoh)</a> added a NEWS entry specifically for it.</p>
<p>I presume it would clash with endless ranges?</p> Ruby master - Bug #18267: Argument forwarding requires parenthesis on method definitionshttps://bugs.ruby-lang.org/issues/18267?journal_id=943332021-10-26T19:03:41ZEregon (Benoit Daloze)
<ul></ul><p>[joke] Maybe a reason to be a little bit more consistent about Ruby syntax and always use parens for method definitions? :D [/joke]</p> Ruby master - Bug #18267: Argument forwarding requires parenthesis on method definitionshttps://bugs.ruby-lang.org/issues/18267?journal_id=943342021-10-26T19:08:43ZEregon (Benoit Daloze)
<ul></ul><p>On a more serious note, <code>def=</code> also has this restriction:</p>
<pre><code>$ 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
</code></pre>
<p>Which I guess is trivially ambiguous because the <code>=</code> could be for an optional arg or for the method body.</p>
<p>Because <code>(...)</code> anyway needs parenthesis on call sites (ambiguous with endless ranges otherwise), I personally think it makes sense to also have parens as a parameter.</p> Ruby master - Bug #18267: Argument forwarding requires parenthesis on method definitionshttps://bugs.ruby-lang.org/issues/18267?journal_id=944212021-10-31T09:28:18Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>Applied in changeset <a class="changeset" title="Argument forwarding definition without parentheses [Bug #18267]" href="https://bugs.ruby-lang.org/projects/ruby-master/repository/git/revisions/13a9597c7ca83fced5738e9345660ae6aef87eb7">git|13a9597c7ca83fced5738e9345660ae6aef87eb7</a>.</p>
<hr>
<p>Argument forwarding definition without parentheses [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: Argument forwarding requires parenthesis on method definitions (Closed)" href="https://bugs.ruby-lang.org/issues/18267">#18267</a>]</p>