Bug #20401
closed
Duplicated when clause warning line number
Added by kddnewton (Kevin Newton) 8 months ago.
Updated 6 months ago.
Description
When you have a duplicated when clause, you get a warning for it. For example:
case foo
when :bar
when :baz
when :bar
end
you get warning: duplicated `when' clause with line 2 is ignored
.
But the when clause that is ignored is the one on line 4, not line 2. It seems like it's warning for the wrong line.
On the otherhand, if you have duplicated hash keys you get:
{
bar: 1,
baz: 1,
bar: 1
}
For the warning: warning: key :bar is duplicated and overwritten on line 4
. So this seems correct.
This behavior was discovered and briefly discussed during the previous dev meeting. The actual warning is
test.rb:4: warning: duplicated 'when' clause with line 2 is ignored
According to @nobu (Nobuyoshi Nakada), this reads "The 'when' clause at line 4 duplicates (conflicts) with (a 'when' clause at) line 2. This is ignored."
Anyway I agree that it is too confusing. I think it would be good if they could improve the English.
- Description updated (diff)
I've merged it for now. Happy to revert or change further if there's any more feedback!
- Status changed from Open to Closed
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0Like0