https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112019-11-05T12:56:46ZRuby Issue Tracking SystemRuby master - Bug #16293: Numbered parameter confirmation in Ruby 2.7https://bugs.ruby-lang.org/issues/16293?journal_id=824862019-11-05T12:56:46Zhsbt (Hiroshi SHIBATA)hsbt@ruby-lang.org
<ul></ul><p>I couldn't understand your request. Please summarize actual and expect behavior with your request.</p> Ruby master - Bug #16293: Numbered parameter confirmation in Ruby 2.7https://bugs.ruby-lang.org/issues/16293?journal_id=824872019-11-05T13:05:12Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul></ul><p>It is difficult for me to analyze this ticket, too. Could you write your expectations and the actual results?</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="c1"># expected: warning: `_1' is used as numbered parameter</span>
<span class="c1"># actual: no warning</span>
<span class="k">def</span> <span class="nf">hgoe</span><span class="p">(</span><span class="n">_1</span><span class="p">)</span>
<span class="k">end</span>
</code></pre>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">def</span> <span class="nf">_1</span><span class="p">;</span> <span class="k">end</span>
<span class="c1"># expected: warning: `_1' is used as numbered parameter</span>
<span class="c1"># actual: no warning</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">_1</span>
</code></pre>
<p>It would be good to write the reason why you expect so. But firstly I need to understand what you expect.</p> Ruby master - Bug #16293: Numbered parameter confirmation in Ruby 2.7https://bugs.ruby-lang.org/issues/16293?journal_id=824892019-11-05T16:18:20Zshevegen (Robert A. Heiler)shevegen@gmail.com
<ul></ul><p>The present behaviour:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">def</span> <span class="nf">_1</span><span class="p">;</span> <span class="k">end</span>
</code></pre>
<p>seems correct and osyo's example of expecting a warning instead seems incorrect to me, unless<br>
he meant it in in some other context. (It is indeed difficult to break the suggestion down<br>
since it is so long. On a semi-related note, I know understand the ruby core team when it<br>
encourages ruby users to explain what they want to see discussed at a developer meeting,<br>
since they have to understand it first. I picture a round of question marks on the<br>
faces ... ;))</p> Ruby master - Bug #16293: Numbered parameter confirmation in Ruby 2.7https://bugs.ruby-lang.org/issues/16293?journal_id=825022019-11-06T00:57:46Zosyo (manga osyo)
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/82502/diff?detail_id=55519">diff</a>)</li></ul> Ruby master - Bug #16293: Numbered parameter confirmation in Ruby 2.7https://bugs.ruby-lang.org/issues/16293?journal_id=825032019-11-06T00:58:26Zosyo (manga osyo)
<ul></ul><p>Thank you all.<br>
I updated text.</p> Ruby master - Bug #16293: Numbered parameter confirmation in Ruby 2.7https://bugs.ruby-lang.org/issues/16293?journal_id=825052019-11-06T03:45:37Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Tracker</strong> changed from <i>Feature</i> to <i>Bug</i></li><li><strong>Backport</strong> set to <i>2.5: UNKNOWN, 2.6: UNKNOWN</i></li></ul><blockquote>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">def</span> <span class="nf">_1</span><span class="p">;</span> <span class="k">end</span>
<span class="c1"># expected: warning: `_1' is used as numbered parameter</span>
<span class="c1"># actual: No warning</span>
<span class="c1"># reason: Because "`x = _0 # expect _0()` outside block. → force warning on Ruby 2.7 and syntax error on Ruby 3" is written in the log</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">_1</span>
</code></pre>
</blockquote>
<p>The "outside block" warning is shown at assignment to a local variable looks like a numbered parameter.<br>
There is no assignment.</p>
<blockquote>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="c1"># expected: warning: `_1' is used as numbered parameter</span>
<span class="c1"># and call to _1()</span>
<span class="c1"># actual: Error: numbered parameter outside block (SyntaxError)</span>
<span class="c1"># reason: Because hoge() method is called with `eval("hoge")`</span>
<span class="nb">eval</span><span class="p">(</span><span class="s2">"_1"</span><span class="p">)</span>
</code></pre>
</blockquote>
<p>This is a bug.<br>
As numbered parameter looks like an ordinary variable now, the warning doesn't make sense.</p>
<blockquote>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">def</span> <span class="nf">_1</span><span class="p">;</span> <span class="k">end</span>
<span class="c1"># expected: warning: `_1' is used as numbered parameter</span>
<span class="c1"># and call to _1()</span>
<span class="c1"># actual: Error: ordinary parameter is defined</span>
<span class="c1"># reason: Because "`1.times{|i| _0 }` → force warning on Ruby 2.7 and syntax error on Ruby 3." is written in the log</span>
<span class="nb">proc</span> <span class="p">{</span> <span class="o">|</span><span class="n">i</span><span class="o">|</span> <span class="n">_1</span> <span class="p">}.</span><span class="nf">call</span> <span class="mi">42</span>
</code></pre>
</blockquote>
<p>The method is irrelevant, Ruby doesn't know if it is defined or not until calling it.<br>
And <code>_1</code> in a block is considered as a numbered parameter, it conflicts with <code>|i|</code>.</p>
<blockquote>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="c1"># expected: warning: `_1' is used as numbered parameter</span>
<span class="c1"># actual: No warning</span>
<span class="c1"># reason: Because define local variable _1 is warning</span>
<span class="k">def</span> <span class="nf">hgoe</span><span class="p">(</span><span class="n">_1</span><span class="p">)</span>
<span class="k">end</span>
</code></pre>
</blockquote>
<p>It is outside block.</p>
<blockquote>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">proc</span> <span class="p">{</span>
<span class="c1"># Warning</span>
<span class="n">_1</span> <span class="o">=</span> <span class="mi">42</span>
<span class="p">}</span>
<span class="nb">proc</span> <span class="p">{</span>
<span class="n">_1</span>
<span class="c1"># expected: warning: `_1' is used as numbered parameter</span>
<span class="c1"># actual: No warning</span>
<span class="c1"># reason: Because define local variable _1 is warning</span>
<span class="n">_1</span> <span class="o">=</span> <span class="mi">42</span>
<span class="p">}</span>
</code></pre>
</blockquote>
<p>This is a bug.<br>
It must be a syntax error.<br>
It was a syntax error in old versions actually.</p> Ruby master - Bug #16293: Numbered parameter confirmation in Ruby 2.7https://bugs.ruby-lang.org/issues/16293?journal_id=825062019-11-06T03:46:03Znobu (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="Numbered parameter cannot appear outside block now [Bug #16293]" href="https://bugs.ruby-lang.org/projects/ruby-master/repository/git/revisions/82e840ad15bba42b399a21de746967a731240ec2">git|82e840ad15bba42b399a21de746967a731240ec2</a>.</p>
<hr>
<p>Numbered parameter cannot appear outside block now [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: Numbered parameter confirmation in Ruby 2.7 (Closed)" href="https://bugs.ruby-lang.org/issues/16293">#16293</a>]</p>