@@ -64,13 +64,16 @@ static void diagSyntacticUseRestrictions(TypeChecker &TC, const Expr *E,
64
64
class DiagnoseWalker : public ASTWalker {
65
65
SmallPtrSet<Expr*, 4 > AlreadyDiagnosedMetatypes;
66
66
SmallPtrSet<DeclRefExpr*, 4 > AlreadyDiagnosedBitCasts;
67
-
68
- // Keep track of acceptable DiscardAssignmentExpr's.
67
+
68
+ // / Keep track of acceptable DiscardAssignmentExpr's.
69
69
SmallPtrSet<DiscardAssignmentExpr*, 2 > CorrectDiscardAssignmentExprs;
70
70
71
71
// / Keep track of the arguments to CallExprs.
72
72
SmallPtrSet<Expr *, 2 > CallArgs;
73
73
74
+ // / Keep track of function call
75
+ ApplyExpr *applyExpr;
76
+
74
77
bool IsExprStmt;
75
78
76
79
public:
@@ -137,6 +140,7 @@ static void diagSyntacticUseRestrictions(TypeChecker &TC, const Expr *E,
137
140
// Check function calls, looking through implicit conversions on the
138
141
// function and inspecting the arguments directly.
139
142
if (auto *Call = dyn_cast<ApplyExpr>(E)) {
143
+ applyExpr = Call;
140
144
// Record call arguments.
141
145
CallArgs.insert (Call->getArg ());
142
146
@@ -247,25 +251,27 @@ static void diagSyntacticUseRestrictions(TypeChecker &TC, const Expr *E,
247
251
248
252
// Diagnose tuple expressions with duplicate element label
249
253
if (auto *tupleExpr = dyn_cast<TupleExpr>(E)) {
250
- auto diagnose = false ;
254
+ if (!applyExpr) {
255
+ auto diagnose = false ;
251
256
252
- llvm::SmallDenseSet<Identifier> names;
253
- names.reserve (tupleExpr->getNumElements ());
257
+ llvm::SmallDenseSet<Identifier> names;
258
+ names.reserve (tupleExpr->getNumElements ());
254
259
255
- for (auto name : tupleExpr->getElementNames ()) {
256
- if (name.empty ())
257
- continue ;
260
+ for (auto name : tupleExpr->getElementNames ()) {
261
+ if (name.empty ())
262
+ continue ;
258
263
259
- if (names.count (name) == 1 ) {
260
- diagnose = true ;
261
- break ;
262
- }
264
+ if (names.count (name) == 1 ) {
265
+ diagnose = true ;
266
+ break ;
267
+ }
263
268
264
- names.insert (name);
265
- }
269
+ names.insert (name);
270
+ }
266
271
267
- if (diagnose) {
268
- TC.diagnose (tupleExpr->getLoc (), diag::tuple_duplicate_label);
272
+ if (diagnose) {
273
+ TC.diagnose (tupleExpr->getLoc (), diag::tuple_duplicate_label);
274
+ }
269
275
}
270
276
}
271
277
0 commit comments