[Sema] Compiler should diagnose non-unique raw values without crashing #64520
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Enums with raw type
: String
use the case name as the raw value if the case is undefined. So two identical case names causes a "raw value for enum case is not unique" error. Additionally, identical case names will always cause a separate redeclaration error regardless of the declared enum raw type.This second error gets diagnosed in CheckRedeclarationRequest in the DeclVisitor. We could add a special case for this situation to ignore the raw value error and defer diagnosing to the DeclVisitor since fixing that error is most correct. For now, I'll fix the crash and let the compiler diagnose both errors.
Fixes rdar://105761206
Fixes #63829