@@ -71,14 +71,12 @@ static void diagSyntacticUseRestrictions(TypeChecker &TC, const Expr *E,
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
-
77
74
bool IsExprStmt;
78
75
79
76
public:
80
77
TypeChecker &TC;
81
78
const DeclContext *DC;
79
+ CallExpr *funcCallExpr = nullptr ;
82
80
83
81
DiagnoseWalker (TypeChecker &TC, const DeclContext *DC, bool isExprStmt)
84
82
: IsExprStmt(isExprStmt), TC(TC), DC(DC) {}
@@ -137,10 +135,13 @@ static void diagSyntacticUseRestrictions(TypeChecker &TC, const Expr *E,
137
135
}
138
136
}
139
137
138
+ if (cast_or_null<CallExpr>(E)) {
139
+ funcCallExpr = cast<CallExpr>(E);
140
+ }
141
+
140
142
// Check function calls, looking through implicit conversions on the
141
143
// function and inspecting the arguments directly.
142
144
if (auto *Call = dyn_cast<ApplyExpr>(E)) {
143
- applyExpr = Call;
144
145
// Record call arguments.
145
146
CallArgs.insert (Call->getArg ());
146
147
@@ -251,7 +252,14 @@ static void diagSyntacticUseRestrictions(TypeChecker &TC, const Expr *E,
251
252
252
253
// Diagnose tuple expressions with duplicate element label
253
254
if (auto *tupleExpr = dyn_cast<TupleExpr>(E)) {
254
- if (!applyExpr) {
255
+ // FIXME: Duplicate labels on enum payloads should be diagnosed
256
+ // when declared, not when called.
257
+ bool isEnumCase = funcCallExpr
258
+ ? cast_or_null<EnumElementDecl>(
259
+ funcCallExpr->getCalledValue ()) != nullptr
260
+ : false ;
261
+
262
+ if (!funcCallExpr || isEnumCase) {
255
263
auto diagnose = false ;
256
264
257
265
llvm::SmallDenseSet<Identifier> names;
0 commit comments