https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112012-03-28T01:07:24ZRuby Issue Tracking SystemRuby master - Feature #5716: duplicated when clause is ignored -> Report which clause it is specifically.https://redmine.ruby-lang.org/issues/5716?journal_id=252732012-03-28T01:07:24Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Assigned</i></li><li><strong>Assignee</strong> set to <i>ko1 (Koichi Sasada)</i></li></ul> Ruby master - Feature #5716: duplicated when clause is ignored -> Report which clause it is specifically.https://redmine.ruby-lang.org/issues/5716?journal_id=257392012-04-09T14:23:10Zko1 (Koichi Sasada)
<ul></ul><p>Thank you for your comment.</p>
<p>I added a small hint on it because if duplicated object was too big, the<br>
output should be ugly.</p>
<p>Does it help you?</p>
<a name="sample-code"></a>
<h1 >sample code<a href="#sample-code" class="wiki-anchor">¶</a></h1>
<p>case nil<br>
when 1<br>
when 1, 1<br>
when 1, 1, 1, 1<br>
when 1, 1<br>
end</p>
<p>#=><br>
../trunk/test.rb:1: warning: duplicated when clause (#1) is ignored<br>
../trunk/test.rb:1: warning: duplicated when clause (#2) is ignored<br>
../trunk/test.rb:1: warning: duplicated when clause (#3) is ignored<br>
../trunk/test.rb:1: warning: duplicated when clause (#4) is ignored<br>
../trunk/test.rb:1: warning: duplicated when clause (#5) is ignored<br>
../trunk/test.rb:1: warning: duplicated when clause (<a class="issue tracker-1 status-5 priority-4 priority-default closed behind-schedule" title="Bug: sprintf() of %f on Windows(MSVCRT) (Closed)" href="https://redmine.ruby-lang.org/issues/6">#6</a>) is ignored<br>
../trunk/test.rb:1: warning: duplicated when clause (#7) is ignored<br>
../trunk/test.rb:1: warning: duplicated when clause (#8) is ignored</p>
<h1>Patch:<br>
Index: compile.c</h1>
<p>--- compile.c (revision 35267)<br>
+++ compile.c (working copy)<br>
@@ -1454,8 +1454,9 @@<br>
rb_hash_aset(map, obj, INT2FIX(lobj->position - (pos+len)));<br>
}<br>
else {</p>
<ul>
<li>
<pre><code> int n = i/2;
rb_compile_warning(RSTRING_PTR(iseq->filename), iobj->line_no,
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> "duplicated when clause is ignored");
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> "duplicated when clause (#%d) is ignored", n);
}
}
hide_obj(map);
</code></pre>
</li>
</ul>
<p>(2011/12/06 19:07), markus heiler wrote:</p>
<blockquote>
<p>Issue <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: duplicated when clause is ignored -> Report which clause it is specifically. (Closed)" href="https://redmine.ruby-lang.org/issues/5716">#5716</a> has been reported by markus heiler.</p>
<hr>
<p>Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: duplicated when clause is ignored -> Report which clause it is specifically. (Closed)" href="https://redmine.ruby-lang.org/issues/5716">#5716</a>: duplicated when clause is ignored -> Report which clause it is specifically.<br>
<a href="http://redmine.ruby-lang.org/issues/5716" class="external">http://redmine.ruby-lang.org/issues/5716</a></p>
<p>Author: markus heiler<br>
Status: Open<br>
Priority: Low<br>
Assignee:<br>
Category:<br>
Target version:</p>
<p>In latest Ruby 1.9.3, if you have warnings enabled, you get information like this here:</p>
<p>foobar.rb:24: warning: duplicated when clause is ignored</p>
<p>This error comes from the file:</p>
<p>compile.c</p>
<p>rb_compile_warning(RSTRING_PTR(iseq->filename), iobj->line_no,<br>
"duplicated when clause is ignored");</p>
<p>This is called, it seems, when the prior function fails:</p>
<p>rb_hash_aset(map, obj, INT2FIX(lobj->position - (pos+len)));</p>
<p>As a user of Ruby, the warning should be better.</p>
<p>Rather than:</p>
<p>foobar.rb:24: warning: duplicated when clause is ignored</p>
<p>I would like to see:</p>
<p>foobar.rb:24: warning: duplicated when clause 'foo' is ignored.</p>
<p>This way, I can scan through the file with the case/when structure<br>
and correct this error. But right now, if you have a very long<br>
case/when structure, you have no idea WHICH clause is duplicated.</p>
<p>The warning message just vaguely says that there is, and this is<br>
not very helpful information.</p>
</blockquote>
<p>--<br>
// SASADA Koichi at atdot dot net</p> Ruby master - Feature #5716: duplicated when clause is ignored -> Report which clause it is specifically.https://redmine.ruby-lang.org/issues/5716?journal_id=257422012-04-09T17:48:18Zshevegen (Robert A. Heiler)shevegen@gmail.com
<ul></ul><p>Hi Koichi Sasada!</p>
<p>I have not tested it yet (will do so at the end of this week),<br>
but I believe it will help me.</p>
<p>Thank you! :)</p> Ruby master - Feature #5716: duplicated when clause is ignored -> Report which clause it is specifically.https://redmine.ruby-lang.org/issues/5716?journal_id=257872012-04-10T15:39:05Zko1 (Koichi Sasada)
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>This issue was solved with changeset r35277.<br>
markus, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<hr>
<ul>
<li>compile.c (iseq_set_sequence): show a hint if there are duplicated<br>
"when" clauses. <a href="https://blade.ruby-lang.org/ruby-core/41502">[ruby-core:41502]</a> [ruby-trunk - Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: duplicated when clause is ignored -> Report which clause it is specifically. (Closed)" href="https://redmine.ruby-lang.org/issues/5716">#5716</a>]</li>
</ul>