diff --git a/Tests/EndToEndTests/TestCases/UnionNarrowing.hylo b/Tests/EndToEndTests/TestCases/UnionNarrowing.hylo index 24facf842..1d8b280d2 100644 --- a/Tests/EndToEndTests/TestCases/UnionNarrowing.hylo +++ b/Tests/EndToEndTests/TestCases/UnionNarrowing.hylo @@ -1,5 +1,9 @@ //- compileAndRun expecting: .success +fun f(_ u: sink Union) -> Bool { + if let _: T = u { true } else { false } +} + public fun main() { var x: Union<{a: Bool}, {b: Int}> = (b: 42) if let y: {b: _} = x { @@ -7,4 +11,8 @@ public fun main() { } else { fatal_error() } + + precondition(f(42 as _)) + precondition(f(42 as _)) + precondition(!f(true as _)) }