Files
swift-mirror/test/Constraints/rdar109419240.swift
Hamish Knight 7a137d6756 [CS] Allow ExprPatterns to be type-checked in the solver
Previously we would wait until CSApply, which
would trigger their type-checking in
`coercePatternToType`. This caused a number of
bugs, and hampered solver-based completion, which
does not run CSApply. Instead, form a conjunction
of all the ExprPatterns present, which preserves
some of the previous isolation behavior (though
does not provide complete isolation).

We can then modify `coercePatternToType` to accept
a closure, which allows the solver to take over
rewriting the ExprPatterns it has already solved.

This then sets the stage for the complete removal
of `coercePatternToType`, and doing all pattern
type-checking in the solver.
2023-06-07 00:35:01 +01:00

16 lines
371 B
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// RUN: %target-typecheck-verify-swift
// rdar://109419240 Make sure we don't crash
enum E { // expected-note {{'E' declared here}}
case e(Int)
}
func foo(_ arr: [E]) -> Int {
return arr.reduce(0) { (total, elem) -> Int in
switch elem {
case let e(x): // expected-error {{cannot find 'e' in scope; did you mean 'E'?}}
return total + x
}
}
}