Skip to content

Commit 5db5733

Browse files
Merge pull request #36904 from LucianoPAlmeida/destructure-fix-it
[Sema] Adding a space in closure parameter destructuring fix in cases closure body is empty
2 parents 149446b + 3d78468 commit 5db5733

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4793,6 +4793,8 @@ bool ClosureParamDestructuringFailure::diagnoseAsError() {
47934793

47944794
if (isMultiLineClosure)
47954795
OS << '\n' << indent;
4796+
else if (closure->getBody()->empty())
4797+
OS << ' ';
47964798

47974799
// Let's form 'let <name> : [<type>]? = arg' expression.
47984800
OS << "let " << parameterOS.str() << " = arg"

test/Constraints/tuple_arguments.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,8 @@ do {
13611361

13621362
let _: ((Int, Int)) -> () = { _ = ($0, $1) } // expected-error {{closure tuple parameter '(Int, Int)' does not support destructuring}}
13631363
let _: ((Int, Int)) -> () = { t, u in _ = (t, u) } // expected-error {{closure tuple parameter '(Int, Int)' does not support destructuring}} {{33-37=(arg)}} {{41-41=let (t, u) = arg; }}
1364+
let _: ((Int, Int)) -> () = { x, y in }
1365+
// expected-error@-1 {{closure tuple parameter '(Int, Int)' does not support destructuring}} {{33-37=(arg)}} {{40-40= let (x, y) = arg; }}
13641366

13651367
let _: (Int, Int) -> () = { _ = $0 } // expected-error {{contextual closure type '(Int, Int) -> ()' expects 2 arguments, but 1 was used in closure body}}
13661368
let _: (Int, Int) -> () = { _ = ($0.0, $0.1) } // expected-error {{contextual closure type '(Int, Int) -> ()' expects 2 arguments, but 1 was used in closure body}}

0 commit comments

Comments
 (0)