-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Open
Labels
compilerThe Swift compiler itselfThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationBug: Diagnostics Quality of Implementationerror handlingfix-itsFeature: diagnostic fix-itsFeature: diagnostic fix-itsgood first issueGood for newcomersGood for newcomersswift 6.3type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis
Description
Description
this is a follow up task to #85818 – in working on that issue, it appeared that the other 'redundant effect' warnings also generally lack fixits that will remove the unneeded effect markers. specifically, we should support fixits for redundant try and unsafe on expressions that do not produce those effects. the 'single value expression' diagnostic variants should also be handled in these cases.
Reproduction
no fixits are produced for these:
@discardableResult
func g() -> Int? { nil }
_ = try g()
_ = try switch g() { default: 0 }
_ = unsafe switch g() { default: 0 }12 | func g() -> Int? { nil }
13 |
14 | _ = try g()
| `- warning: no calls to throwing functions occur within 'try' expression [no_throw_in_try]
15 | _ = try switch g() { default: 0 }
16 | _ = unsafe switch g() { default: 0 }
13 |
14 | _ = try g()
15 | _ = try switch g() { default: 0 }
| `- warning: 'try' has no effect on 'switch' expression [effect_marker_on_single_value_stmt]
16 | _ = unsafe switch g() { default: 0 }
17 |
14 | _ = try g()
15 | _ = try switch g() { default: 0 }
16 | _ = unsafe switch g() { default: 0 }
| `- warning: 'unsafe' has no effect on 'switch' expression [effect_marker_on_single_value_stmt]
17 |
Expected behavior
the redundant effect markers should have fixits offering to remove them
Environment
Swift version 6.3-dev (LLVM 35f48306184cd25, Swift a69dbb3)
Target: x86_64-unknown-linux-gnu
Additional information
No response
Metadata
Metadata
Assignees
Labels
compilerThe Swift compiler itselfThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationBug: Diagnostics Quality of Implementationerror handlingfix-itsFeature: diagnostic fix-itsFeature: diagnostic fix-itsgood first issueGood for newcomersGood for newcomersswift 6.3type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis