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

[SR-1306] Inconsistent behavior with labeled type parameters #43914

Closed
natecook1000 opened this issue Apr 24, 2016 · 0 comments
Closed

[SR-1306] Inconsistent behavior with labeled type parameters #43914

natecook1000 opened this issue Apr 24, 2016 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@natecook1000
Copy link
Member

Previous ID SR-1306
Radar None
Original Reporter @natecook1000
Type Bug
Status Resolved
Resolution Duplicate
Environment

Swift 2.2 and Swift 3 master branch

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: 109c04a65b17188a6ae294c4a3e1ae14

duplicates:

  • SR-899 .self can be omitted if a function has only one parameter

Issue Description:

When a metatype type is used as a function parameter, whether or not the passed type requires ".self" depends on whether the parameter has an external label.

func foo<T>(type: T.Type) {
    print(T)
}

func bar<T>(baz type: T.Type) {
    print(T)
}

foo(String.self)        // ok
foo(String)             // ok
bar(baz: String.self)   // ok
bar(baz: String)        // error

The error output looks like this:

<REPL Input>:1:5: error: cannot create a single-element tuple with an element label
bar(baz: String)        // error
    ^~~~~
    
<REPL Input>:1:4: error: missing argument label 'baz:' in call
bar(baz: String)        // error
   ^
   baz: 

Whatever the correct behavior is should be consistent between foo(_:) and bar(baz:).

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
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. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

1 participant