Skip to content

Conversions of Function returning function fail in 6.2 #82397

Closed
@kntkymt

Description

@kntkymt

Description

Conversions of Function returning function fail in 6.2.

let a: () -> () -> Void = {{}}
let _: (() -> () -> Void)? = a // 🔴 Cannot convert value of type '() -> Void' to specified type '() -> () -> Void'

Reproduction

compile above code.

Expected behavior

compiler outputs no error.

Environment

swiftc --version
swift-driver version: 1.127.4.2 Apple Swift version 6.2 (swiftlang-6.2.0.9.909 clang-1700.3.9.907)
Target: arm64-apple-macosx15.0

Additional information

regression of #78377

- if (convertTo->is<FunctionType>())
+ if (convertTo->is<FunctionType>() && !resultType->is<FunctionType>())
    return false;

Since the new condition doesn’t handle the case where both lhs and rhs have the same curry level, conversions of function-returning functions are incorrectly repaired by repairByInsertingExplicitCall.

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfexpressionsFeature: expressionsimplicit conversionsFeature: implicit conversionstype checkerArea → compiler: Semantic analysis

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions