mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
So, it turns out that if the type checker were to re-write the Expr node of a single-expression closure body, we were never writing the modified body Expr back into the closure Expr. This meant that if the closure expression's body were something like 'self.foo', we'd leave an UnresolvedDotExpr in the AST and most likely end up crashing down the line. This has been responsible for about 4700 crash reports over the past several months. (Though, oddly enough, we didn't seem to hit it in the crash suite.) Thanks to Argyrios for pushing on this one! rdar://problem/19840785 Swift SVN r25774
47 lines
834 B
Swift
47 lines
834 B
Swift
// RUN: %target-parse-verify-swift
|
|
|
|
struct Blob {}
|
|
|
|
func withBlob(block: Blob -> ()) {}
|
|
|
|
protocol Binding {}
|
|
extension Int: Binding {}
|
|
extension Double: Binding {}
|
|
extension String: Binding {}
|
|
extension Blob: Binding {}
|
|
|
|
struct Stmt {
|
|
func bind(values: Binding?...) -> Stmt {
|
|
return self
|
|
}
|
|
|
|
func bind(values: [Binding?]) -> Stmt {
|
|
return self
|
|
}
|
|
|
|
func bind(values: [String: Binding?]) -> Stmt {
|
|
return self
|
|
}
|
|
}
|
|
|
|
let stmt = Stmt()
|
|
withBlob { stmt.bind(1, 2.0, "3", $0) }
|
|
withBlob { stmt.bind([1, 2.0, "3", $0]) }
|
|
withBlob { stmt.bind(["1": 1, "2": 2.0, "3": "3", "4": $0]) }
|
|
|
|
// <rdar://problem/19840785>
|
|
// We shouldn't crash on the call to 'a.dispatch' below.
|
|
class A {
|
|
func dispatch(f : ()-> Void) {
|
|
f()
|
|
}
|
|
}
|
|
|
|
class C {
|
|
var prop = 0
|
|
var a = A()
|
|
|
|
func act() {
|
|
a.dispatch({() -> Void in self.prop})
|
|
}
|
|
} |