https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112018-06-02T04:33:01ZRuby Issue Tracking SystemRuby master - Feature #14808: Last token of endless range should have EXPR_ENDhttps://bugs.ruby-lang.org/issues/14808?journal_id=723472018-06-02T04:33:01Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Rejected</i></li></ul><p>That code is valid syntax in both versions, and it is <em>not</em> an endless range in the trunk as well as 2.5.<br>
As <code>..</code> is an infix operator and requires the RHS, newlines following it are just ignored.<br>
So it equals to:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">case</span> <span class="mi">5</span>
<span class="k">when</span> <span class="p">(</span><span class="mi">3</span><span class="o">..</span><span class="nb">puts</span><span class="p">(</span><span class="kp">true</span><span class="p">))</span>
<span class="k">end</span>
</code></pre>
<p>It results in an error at runtime in 2.5, not a syntax error.</p>
<pre><code>$ ruby2.5 -rripper -e 'case 5' -e 'when 3..' -e 'puts(true)' -e end
true
Traceback (most recent call last):
-e:3:in `<main>': bad value for range (ArgumentError)
</code></pre>
<p>To put an endless range there, use parentheses.</p> Ruby master - Feature #14808: Last token of endless range should have EXPR_ENDhttps://bugs.ruby-lang.org/issues/14808?journal_id=723922018-06-05T06:26:02Zaycabta (aycabta .)aycabta@gmail.com
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-5 priority-4 priority-default closed" href="/issues/14824">Bug #14824</a>: Endless Range Support in irb</i> added</li></ul>