Files
swift-mirror/test/Constraints/issue-87552.swift
Hamish Knight 0149f32483 [CS] Avoid binding unwrapped type for SingleValueStmtExpr
Like closure results, we want the conversion to happen within the
individual branches of the expression. This avoids unhelpful diagnostics
around `nil` literals.
2026-02-26 23:53:16 +00:00

18 lines
549 B
Swift

// RUN: %target-typecheck-verify-swift
// https://github.com/swiftlang/swift/issues/87552
struct S {
init(_ xs: some Sequence<Int>) {}
}
func foo<T>(_ fn: T?) -> [T] { [] }
// FIXME: This ought to work
let _ = S(foo(.init())) // expected-error {{member 'init()' in 'Int?' produces result of type 'Int', but context expects 'Int?'}}
let _ = S(foo({ .init() }()))
let _ = S(foo(if .random() { .init() } else { .init() })) // expected-error {{'if' may only be used as expression}}
let _ = S.init(foo(.init()))
let _ = S.init(foo({ .init() }()))