From: Stefano Mioli Date: 2011-07-17T08:13:55+09:00 Subject: Re: duplicated when clause is ignored On 7/16/11 11:50 PM, Marc Heiler wrote: > foobar.rb:156: warning: duplicated when clause is ignored > > Is there any way for Ruby to tell me which are duplicated though? Not that I know of, rb_compile_warning() is invoked from compile.c with the line number on which the 'case' statement is. I agree that it would be a nice feature. The problem, though, seems to be elsewhere. How many 'when' clauses are there in your script? Is it so high to make a manual check too difficult? If so, that might be a code smell, meaning that you should refactor your code. From a couple of tests I made, I observed something interesting. This: x = 1 case x when 0 when 1 when 1 end will cause the warning to appear. This, on the other hand: x = 1 case x when 0 when 1 when 1 + 0 when 1 end is enough to fool iseq_set_sequence(), making it print out no warnings at all, even though we still *do* have a duplicate 'when' clause (let alone that there are actually 3 duplicated clauses). I wonder if I should file a ticket. -- Stefano Mioli