File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
validation-test/Sema/type_checker_crashers_fixed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -2479,21 +2479,31 @@ bool ClosureParamDestructuringFailure::diagnoseAsError() {
2479
2479
auto bodyStmts = closureBody->getElements ();
2480
2480
2481
2481
SourceLoc bodyLoc;
2482
+ SourceLoc inLoc = closure->getInLoc ();
2483
+ // If location for `in` is unknown we can't proceed
2484
+ // since we'll not be able to figure out source line
2485
+ // to place the fix-it on.
2486
+ if (inLoc.isInvalid ())
2487
+ return true ;
2488
+
2482
2489
// If the body is empty let's put the cursor
2483
2490
// right after "in", otherwise make it start
2484
2491
// location of the first statement in the body.
2485
2492
if (bodyStmts.empty ())
2486
- bodyLoc = Lexer::getLocForEndOfToken (sourceMgr, closure-> getInLoc () );
2493
+ bodyLoc = Lexer::getLocForEndOfToken (sourceMgr, inLoc );
2487
2494
else
2488
2495
bodyLoc = bodyStmts.front ().getStartLoc ();
2489
2496
2497
+ if (bodyLoc.isInvalid ())
2498
+ return true ;
2499
+
2490
2500
SmallString<64 > fixIt;
2491
2501
llvm::raw_svector_ostream OS (fixIt);
2492
2502
2493
2503
// If this is multi-line closure we'd have to insert new lines
2494
2504
// in the suggested 'let' to keep the structure of the code intact,
2495
2505
// otherwise just use ';' to keep everything on the same line.
2496
- auto inLine = sourceMgr.getLineNumber (closure-> getInLoc () );
2506
+ auto inLine = sourceMgr.getLineNumber (inLoc );
2497
2507
auto bodyLine = sourceMgr.getLineNumber (bodyLoc);
2498
2508
auto isMultiLineClosure = bodyLine > inLine;
2499
2509
auto indent =
Original file line number Diff line number Diff line change
1
+ // RUN: not %target-swift-frontend %s -typecheck
2
+
3
+ func foo( ) -> [ String ] {
4
+ let dict : [ String : String ] = [ : ]
5
+ return dict . filter ( { ( _
You can’t perform that action at this time.
0 commit comments