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-3806] Type checker rejects single defaulted generic argument #46391

Closed
belkadan opened this issue Jan 31, 2017 · 3 comments
Closed

[SR-3806] Type checker rejects single defaulted generic argument #46391

belkadan opened this issue Jan 31, 2017 · 3 comments
Assignees
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

@belkadan
Copy link
Contributor

Previous ID SR-3806
Radar None
Original Reporter @belkadan
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee @slavapestov
Priority Medium

md5: b262e8079c0f5640a45de922083a508c

relates to:

  • SR-3808 SILGen crash with single defaulted generic argument

Issue Description:

public protocol Initializable {
  init()
}
struct GenericBase<T: Initializable> {
  public init(_ value: T = T()) {}
}
struct Reinitializable: Initializable {
  init() {}
}
func test() {
  _ = GenericBase<Reinitializable>()
}
<stdin>:11:35: error: '()' is not convertible to 'Reinitializable'
  _ = GenericBase<Reinitializable>()
                                  ^~

Note that GenericBase<Reinitializable>.init() works fine.

@belkadan
Copy link
Contributor Author

(and by "works fine" I mean "crashes in SILGen, hopefully soon to be fixed")

@slavapestov
Copy link
Member

Interestingly this works in -swift-version 4 mode.

@slavapestov
Copy link
Member

Swift 3 mode is gone on master, and this works in Swift 4. Adding a test case in #19162

@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

2 participants