// RUN: %target-swift-frontend %s -o /dev/null -verify -emit-sil struct Box { var value: T } class Klass {} func myPrint(_ x: inout Box) -> () { print(x) } func testError() -> (() -> ()) { @_semantics("boxtostack.mustbeonstack") var x = Box(value: Klass()) // expected-error {{Can not promote value from heap to stack due to value escaping}} let result = { // expected-note {{value escapes here}} myPrint(&x) } return result } func main() { testError()() } main()