Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update duplicated 'when' clause warning message #10776

Merged
merged 2 commits into from
May 24, 2024

Conversation

kddnewton
Copy link
Contributor

Previously for duplicated when clauses like:

1: case foo
2: when :bar
3: when :baz
4: when :bar
5: end

You would get a warning like:

warning: duplicated 'when' clause with line 2 is ignored

which is supposed to read as in:

"The 'when' clause at line 4 duplicates (conflicts) with (a 'when' clause at) line 2. This is ignored."

The issue is that it can be read as the clause on line 2 is ignored. This commit updates the warning message to instead say:

warning: 'when' clause on line 4 duplicates 'when' clause on line 2 and is ignored

This makes it clear which clause is begin duplicated and which clause is being ignored.

This commit fixes both parsers.

@kddnewton kddnewton requested a review from nobu May 15, 2024 19:01

This comment has been minimized.

@kddnewton kddnewton force-pushed the duplicated-when branch 3 times, most recently from db0eba0 to 824b4b6 Compare May 15, 2024 19:24
@kddnewton kddnewton force-pushed the duplicated-when branch 4 times, most recently from 43f04dd to 4030673 Compare May 15, 2024 20:41
@Edwing123
Copy link
Contributor

Edwing123 commented May 18, 2024

At first I thought the one on line 4 was being ignored, I think something like the following is an option, too:

warning: 'when' clause on line 2 is ignored due to duplicated 'when' clause on line 4.

Or

warning: 'when' clause on line 2 is ignored because it's duplicated by 'when' clause on line 4.

@kddnewton
Copy link
Contributor Author

The one on line 4 is ignored, the first one wins.

@Edwing123
Copy link
Contributor

The one on line 4 is ignored, the first one wins.

I see.

@kddnewton kddnewton merged commit 47f0965 into ruby:master May 24, 2024
104 checks passed
@kddnewton kddnewton deleted the duplicated-when branch May 24, 2024 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants