Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non generic functions accept generic specialization syntax in some cases #73749

Open
TeamPuzel opened this issue May 20, 2024 · 1 comment
Open
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@TeamPuzel
Copy link

TeamPuzel commented May 20, 2024

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

@TeamPuzel TeamPuzel added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels May 20, 2024
@tbkka
Copy link
Contributor

tbkka commented May 28, 2024

CC: @slavapestov @xedin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

2 participants