-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationBug: Diagnostics Quality of ImplementationgenericsFeature: generic declarations and typesFeature: generic declarations and typestype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis
Description
This code does not produce any diagnostics:
struct S<T> {
func f<T>(_: T) {}
}Then, confusing errors are produced when the above code is called incorrectly:
S().f(1) // error: Generic parameter 'T' could not be inferredThis is fundamentally because the type parameter T is shadowed in func f. Usually, programmers do this by accident - they meant for the inner T to match the outer T. The compiler should emit a warning when type parameters are shadowed like this, with two notes for possible fixes:
- A note to remove the shadowed type parameter with a corresponding fix-it.
- A note to rename the shadowed type parameter.
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationBug: Diagnostics Quality of ImplementationgenericsFeature: generic declarations and typesFeature: generic declarations and typestype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis