File tree 1 file changed +13
-0
lines changed
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -4739,6 +4739,19 @@ void ConstraintSystem::diagnoseFailureFor(SyntacticElementTarget target) {
4739
4739
} else if (target.getAsUninitializedVar ()) {
4740
4740
DE.diagnose (target.getLoc (), diag::failed_to_produce_diagnostic);
4741
4741
} else if (target.isForEachPreamble ()) {
4742
+ auto forEachStmt = target.getAsForEachStmt ();
4743
+ auto sequence = forEachStmt->getParsedSequence ();
4744
+ // Fix for a specific case:
4745
+ //
4746
+ // func example(_ a: Int) -> [Int] { [] }
4747
+ // for _ in foo(-) {}
4748
+ for (auto &arg: sequence->getArgs ()->getArgExprs ()) {
4749
+ if (auto *overloadedDeclRefExpr = dyn_cast<OverloadedDeclRefExpr>(arg)) {
4750
+ DE.diagnose (target.getLoc (), diag::type_of_expression_is_ambiguous)
4751
+ .highlight (target.getSourceRange ());
4752
+ return ;
4753
+ }
4754
+ }
4742
4755
DE.diagnose (target.getLoc (), diag::failed_to_produce_diagnostic);
4743
4756
} else {
4744
4757
// Emit a poor fallback message.
You can’t perform that action at this time.
0 commit comments