Skip to content

Upgrade the warning about non-escaping parameter exclusivity to an error. #10988

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions test/expr/postfix/call/noescape-param-exclusivity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
}
}
Expand All @@ -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}}
Expand Down