mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
We already had bookkeeping to track which statement in a multi-statement closure we were looking at, but this was only used for the 'reasonable time' diagnostic in the case that we hit the expression timer, which was almost never hit, and is now off by default. The scope, memory, and trial limits couldn't use this information, so they would always diagnose the entire target being type checked. Move it up from ExpressionTimer to ConstraintSystem, so that we get the right source location there too. Also, factor out some code duplication in BuilderTransform to ensure we get the same benefit for result builders applied to function bodies too.
20 lines
642 B
Swift
20 lines
642 B
Swift
// RUN: %target-typecheck-verify-swift -solver-scope-threshold=10
|
|
|
|
// Note: the scope threshold is intentionally set low so that the expression will fail.
|
|
//
|
|
// The purpose of the test is to ensure the diagnostic points at the second statement in
|
|
// the closure, and not the closure itself.
|
|
//
|
|
// If the expression becomes very fast and we manage to type check it with fewer than
|
|
// 10 scopes, please *do not* remove the expected error! Instead, make the expression
|
|
// more complex again.
|
|
|
|
let s = ""
|
|
let n = 0
|
|
|
|
let closure = {
|
|
let _ = 0
|
|
let _ = "" + s + "" + s + "" + s + "" + n + "" // expected-error {{reasonable time}}
|
|
let _ = 0
|
|
}
|