-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed as duplicate of#74857
Closed as duplicate of#74857
Copy link
Labels
accepts invalidBug: Accepts invalidBug: Accepts invalidbugA 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 itselfexpressionsFeature: expressionsFeature: expressionsgenericsFeature: generic declarations and typesFeature: generic declarations and typesswift 6.0type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis
Description
Description
Swift is allowing a syntax mistake.
Reproduction
It seems that a function can "accept" explicit generic parameters in this situation:
func z() -> Int { 1 } // Non generic function
func z<T: FloatingPoint>() -> T { 1 } // Generic overload of that function
let y: Int = z<Float>() // Nonsense syntax compiles (the parameter is ignored but there is no error)
It does not seem to happen when either of the overloads is commented out, catching the invalid syntax.
Expected behavior
An error message detecting the misleading syntax.
Environment
Apple Swift version 6.0-dev (LLVM 3417addab6ff197, Swift d677b7c23fd6355)
Target: arm64-apple-macosx14.0
Additional information
No response
Metadata
Metadata
Assignees
Labels
accepts invalidBug: Accepts invalidBug: Accepts invalidbugA 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 itselfexpressionsFeature: expressionsFeature: expressionsgenericsFeature: generic declarations and typesFeature: generic declarations and typesswift 6.0type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis