Skip to content

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

@swift-ci

Description

@swift-ci
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselftype checkerArea → compiler: Semantic analysis

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions