From aa5db1f86bb44cb745ac05b4c542c6350cda1386 Mon Sep 17 00:00:00 2001 From: John McCall Date: Sat, 15 Jul 2017 15:42:30 -0400 Subject: [PATCH] Upgrade the warning about non-escaping parameter exclusivity to an error now that Dispatch has fixed its violations. --- include/swift/AST/DiagnosticsSema.def | 3 +-- test/expr/postfix/call/noescape-param-exclusivity.swift | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/swift/AST/DiagnosticsSema.def b/include/swift/AST/DiagnosticsSema.def index d76a086af53fb..4c65a10b0cb85 100644 --- a/include/swift/AST/DiagnosticsSema.def +++ b/include/swift/AST/DiagnosticsSema.def @@ -267,8 +267,7 @@ ERROR(incorrect_explicit_closure_result,none, "declared closure result %0 is incompatible with contextual type %1", (Type, Type)) -// FIXME: make this an error when we've fixed the Dispatch problem. -WARNING(err_noescape_param_call,none, +ERROR(err_noescape_param_call,none, "passing a %select{|closure which captures a }1non-escaping function " "parameter %0 to a call to a non-escaping function parameter can allow " "re-entrant modification of a variable", diff --git a/test/expr/postfix/call/noescape-param-exclusivity.swift b/test/expr/postfix/call/noescape-param-exclusivity.swift index 41af147b7710c..0c658d3d1f7b0 100644 --- a/test/expr/postfix/call/noescape-param-exclusivity.swift +++ b/test/expr/postfix/call/noescape-param-exclusivity.swift @@ -3,13 +3,13 @@ // FIXME: make these errors func test0(fn: (() -> ()) -> ()) { - fn { fn {} } // expected-warning {{passing a closure which captures a non-escaping function parameter 'fn' to a call to a non-escaping function parameter can allow re-entrant modification of a variable}} + fn { fn {} } // expected-error {{passing a closure which captures a non-escaping function parameter 'fn' to a call to a non-escaping function parameter can allow re-entrant modification of a variable}} } func test1(fn: (() -> ()) -> ()) { // expected-note {{parameter 'fn' is implicitly non-escaping}} // TODO: infer that this function is noescape from its captures func foo() { - fn { fn {} } // expected-warning {{can allow re-entrant modification}} + fn { fn {} } // expected-error {{can allow re-entrant modification}} // expected-error@-1 {{declaration closing over non-escaping parameter 'fn' may allow it to escape}} } } @@ -25,7 +25,7 @@ func test2(x: inout Int, fn: (() -> ()) -> ()) { } func test3(fn: (() -> ()) -> ()) { - { myfn in myfn { fn {} } }(fn) // expected-warning {{can allow re-entrant modification}} + { myfn in myfn { fn {} } }(fn) // expected-error {{can allow re-entrant modification}} } func test4(fn: (() -> ()) -> ()) { // expected-note {{parameter 'fn' is implicitly non-escaping}}