Skip to content

Commit 4c2deab

Browse files
committed
---
yaml --- r: 341951 b: refs/heads/rxwei-patch-1 c: b839e07 h: refs/heads/master i: 341949: d433bf5 341947: 1585e77 341943: 2ee4523 341935: 14a9d6c 341919: 09a5670 341887: 9491508
1 parent 39e9856 commit 4c2deab

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-08-18-a: b10b1fce14385faa6d44f6b933e95
10151015
refs/heads/rdar-43033749-fix-batch-mode-no-diags-swift-5.0-branch: a14e64eaad30de89f0f5f0b2a782eed7ecdcb255
10161016
refs/heads/revert-19006-error-bridging-integer-type: 8a9065a3696535305ea53fe9b71f91cbe6702019
10171017
refs/heads/revert-19050-revert-19006-error-bridging-integer-type: ecf752d54b05dd0a20f510f0bfa54a3fec3bcaca
1018-
refs/heads/rxwei-patch-1: 8092dd9ad747a35f8f1120d3dcf64506d154265c
1018+
refs/heads/rxwei-patch-1: b839e07c1277a2e974da297b995d89efce0f0f60
10191019
refs/heads/shahmishal-patch-1: e58ec0f7488258d42bef51bc3e6d7b3dc74d7b2a
10201020
refs/heads/typelist-existential: 4046359efd541fb5c72d69a92eefc0a784df8f5e
10211021
refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-08-20-a: 4319ba09e4fb8650ee86061075c74a016b6baab9

branches/rxwei-patch-1/include/swift/AST/DiagnosticsParse.def

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,9 @@ ERROR(extra_rbracket,PointsToFirstBadToken,
763763
ERROR(extra_colon,PointsToFirstBadToken,
764764
"unexpected ':' in type; did you mean to write a dictionary type?", ())
765765
WARNING(subscript_collection_element_invalid_index, none,
766-
"index '%0' in subscript expression is out of bounds", (StringRef))
766+
"index '%0' in subscript expression is out of bounds", (StringRef))
767+
NOTE(subscript_collection_element_fix_it, none, "did you mean to write two "
768+
"array literals instead?", ())
767769

768770
// Tuple Types
769771
ERROR(expected_rparen_tuple_type_list,none,

branches/rxwei-patch-1/lib/Parse/ParseExpr.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3509,6 +3509,12 @@ void Parser::validateCollectionElement(ParserResult<Expr> element) {
35093509
diag::subscript_collection_element_invalid_index,
35103510
indexExpr->getDigitsText());
35113511
diag.highlight(subscriptExpr->getSourceRange());
3512+
diag.flush();
3513+
3514+
auto note = diagnose(subscriptExpr->getLoc(),
3515+
diag::subscript_collection_element_fix_it);
3516+
note.fixItInsertAfter(baseExpr->getRBracketLoc(), ",");
3517+
35123518
element.setIsParseError();
35133519
}
35143520
}

branches/rxwei-patch-1/test/type/array.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,6 @@ func passAssocType<T : HasAssocType>(_ t: T) {
117117
// SR-11134
118118

119119
let sr_11134_1 = [["a"][0]] // Ok
120-
let sr_11134_2 = [["a"][1]] // expected-warning {{index '1' in subscript expression is out of bounds}}
120+
let sr_11134_2 = [["a"][1]] // expected-warning {{index '1' in subscript expression is out of bounds}} // expected-note {{did you mean to write two array literals instead?}}{{24-24=,}}
121+
let sr_11134_3 = [[1, 1, 1], [], [4, 5, 6, 7], [0], [], [] [42]] // expected-warning {{index '42' in subscript expression is out of bounds}} // expected-note {{did you mean to write two array literals instead?}}{{59-59=,}}
121122

122-
let sr_11134_3 = [[1, 1, 1], [], [4, 5, 6, 7], [0], [], [] [42]] // expected-warning {{index '42' in subscript expression is out of bounds}}

0 commit comments

Comments
 (0)