Commit 4308a14
committed
[Sema] Compiler should diagnose non-unique raw values without crashing
Enums with raw type `: String ` use the case name as the raw
value. So, two identical case names cause an identical raw value
error. Also, identical case names cause a separate redeclaration
error. The second error is diagnosed in a separate request in the
DeclVisitor. We may need a special case for this situation to
ignore the first error and defer diagnosing to the
CheckRedeclarationRequest. For now we will diagnose both errors.
`enum Foo : String {
case Bar
case Bar = "FooBar" // redclaration error only
case Bar // redeclaration and raw value error
}`1 parent ac134e4 commit 4308a14
2 files changed
+21
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1342 | 1342 | | |
1343 | 1343 | | |
1344 | 1344 | | |
1345 | | - | |
1346 | | - | |
1347 | | - | |
| 1345 | + | |
1348 | 1346 | | |
1349 | 1347 | | |
1350 | 1348 | | |
| |||
1356 | 1354 | | |
1357 | 1355 | | |
1358 | 1356 | | |
| 1357 | + | |
1359 | 1358 | | |
1360 | 1359 | | |
1361 | 1360 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
364 | 364 | | |
365 | 365 | | |
366 | 366 | | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
367 | 386 | | |
368 | 387 | | |
369 | 388 | | |
| |||
0 commit comments