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-13135] Type inference regression in Swift 5.3/Xcode 12 Beta #55581

Closed
swift-ci opened this issue Jul 2, 2020 · 3 comments
Closed

[SR-13135] Type inference regression in Swift 5.3/Xcode 12 Beta #55581

swift-ci opened this issue Jul 2, 2020 · 3 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

@swift-ci
Copy link
Collaborator

swift-ci commented Jul 2, 2020

Previous ID SR-13135
Radar rdar://problem/65088975
Original Reporter DeeSee (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Xcode 12 Beta 1/macOS Catalina 10.15.5 (19F101)

Additional Detail from JIRA
Votes 4
Component/s Compiler
Labels Bug, TypeChecker
Assignee DeeSee (JIRA)
Priority Medium

md5: de79c846cf09afec4f64b77b416ac261

Issue Description:

Consider this code sample:

private struct Foo {
  var bar: [Int] = []
}

let baz: Int? = nil

func foo<T: Equatable>(
  _ a: @autoclosure () throws -> T,
  _ b: @autoclosure () throws -> T
) {}

foo(Foo().bar, [baz]) 

It runs perfectly fine in Xcode 11.5 playground, while Xcode 12 Beta 1 outputs the following error:

error: test.playground:11:17: error: cannot convert value of type 'Int?' to expected element type 'Array<Int>.ArrayLiteralElement' (aka 'Int')
foo(Foo().bar, [baz])

Please note that @autoclosure attribute for foo's parameters is a required precondition for this issue.

@typesanitizer
Copy link

Seems like covariance in the return type is not working properly for autoclosures? Here's a slightly reduced example:

let x : [Int] = []
let y: Int? = nil
func f<T>(_: @autoclosure () -> T, _: @autoclosure () -> T) {}
f(x, [y])

Thanks for reporting with a small example! 🙂

@typesanitizer
Copy link

@swift-ci create

@xedin
Copy link
Member

xedin commented Jul 6, 2020

Fixed by #32724 Please use next available nightly build of master to verify and close.

@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

3 participants