[ruby-core:117368] [Ruby master Bug#20401] Duplicated when clause warning line number

Issue #20401 has been reported by kddnewton (Kevin Newton). ---------------------------------------- Bug #20401: Duplicated when clause warning line number https://bugs.ruby-lang.org/issues/20401 * Author: kddnewton (Kevin Newton) * Status: Open * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- When you have a duplicated when clause, you get a warning for it. For example: ```ruby 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. -- https://bugs.ruby-lang.org/

Issue #20401 has been updated by kddnewton (Kevin Newton). On the otherhand, if you have duplicated hash keys you get: ```ruby { bar: 1, baz: 1, bar: 1 } ``` For the warning: `warning: key :bar is duplicated and overwritten on line 4`. So this seems correct. ---------------------------------------- Bug #20401: Duplicated when clause warning line number https://bugs.ruby-lang.org/issues/20401#change-107527 * Author: kddnewton (Kevin Newton) * Status: Open * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- When you have a duplicated when clause, you get a warning for it. For example: ```ruby 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. -- https://bugs.ruby-lang.org/

Issue #20401 has been updated by mame (Yusuke Endoh). 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, 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. ---------------------------------------- Bug #20401: Duplicated when clause warning line number https://bugs.ruby-lang.org/issues/20401#change-107529 * Author: kddnewton (Kevin Newton) * Status: Open * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- When you have a duplicated when clause, you get a warning for it. For example: ```ruby 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. -- https://bugs.ruby-lang.org/

Issue #20401 has been updated by kddnewton (Kevin Newton). I've updated the message to say: ``` 'when' clause on line 4 duplicates 'when' clause on line 2 and is ignored ``` I hope this is okay, I believe it is much more clear. The PR is here: https://github.com/ruby/ruby/pull/10776. @nobu or @mame could you review? ---------------------------------------- Bug #20401: Duplicated when clause warning line number https://bugs.ruby-lang.org/issues/20401#change-108302 * Author: kddnewton (Kevin Newton) * Status: Open * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- When you have a duplicated when clause, you get a warning for it. For example: ```ruby 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. -- https://bugs.ruby-lang.org/

Issue #20401 has been updated by kddnewton (Kevin Newton). I've merged it for now. Happy to revert or change further if there's any more feedback! ---------------------------------------- Bug #20401: Duplicated when clause warning line number https://bugs.ruby-lang.org/issues/20401#change-108425 * Author: kddnewton (Kevin Newton) * Status: Open * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- When you have a duplicated when clause, you get a warning for it. For example: ```ruby 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. -- https://bugs.ruby-lang.org/
participants (2)
-
kddnewton (Kevin Newton)
-
mame (Yusuke Endoh)