File tree Expand file tree Collapse file tree 2 files changed +34
-6
lines changed Expand file tree Collapse file tree 2 files changed +34
-6
lines changed Original file line number Diff line number Diff line change @@ -1872,12 +1872,8 @@ class PreCheckResultBuilderApplication : public ASTWalker {
1872
1872
E, DC, /* replaceInvalidRefsWithErrors=*/ true );
1873
1873
HasError |= transaction.hasErrors ();
1874
1874
1875
- if (!HasError) {
1876
- E->forEachChildExpr ([&](Expr *expr) {
1877
- HasError |= isa<ErrorExpr>(expr);
1878
- return HasError ? nullptr : expr;
1879
- });
1880
- }
1875
+ if (!HasError)
1876
+ HasError |= containsErrorExpr (E);
1881
1877
1882
1878
if (SuppressDiagnostics)
1883
1879
transaction.abort ();
@@ -1899,6 +1895,29 @@ class PreCheckResultBuilderApplication : public ASTWalker {
1899
1895
return std::make_pair (true , S);
1900
1896
}
1901
1897
1898
+ // / Check whether given expression (including single-statement
1899
+ // / closures) contains `ErrorExpr` as one of its sub-expressions.
1900
+ bool containsErrorExpr (Expr *expr) {
1901
+ bool hasError = false ;
1902
+
1903
+ expr->forEachChildExpr ([&](Expr *expr) -> Expr * {
1904
+ hasError |= isa<ErrorExpr>(expr);
1905
+ if (hasError)
1906
+ return nullptr ;
1907
+
1908
+ if (auto *closure = dyn_cast<ClosureExpr>(expr)) {
1909
+ if (shouldTypeCheckInEnclosingExpression (closure)) {
1910
+ hasError |= containsErrorExpr (closure->getSingleExpressionBody ());
1911
+ return hasError ? nullptr : expr;
1912
+ }
1913
+ }
1914
+
1915
+ return expr;
1916
+ });
1917
+
1918
+ return hasError;
1919
+ }
1920
+
1902
1921
// / Ignore patterns.
1903
1922
std::pair<bool , Pattern*> walkToPatternPre (Pattern *pat) override {
1904
1923
return { false , pat };
Original file line number Diff line number Diff line change @@ -727,4 +727,13 @@ struct TuplifiedStructWithInvalidClosure {
727
727
42
728
728
}
729
729
}
730
+
731
+ @TupleBuilder var nestedErrorsDiagnosedByParser : some Any {
732
+ tuplify ( true ) { _ in
733
+ tuplify { _ in
734
+ self . // expected-error {{expected member name following '.'}}
735
+ }
736
+ 42
737
+ }
738
+ }
730
739
}
You can’t perform that action at this time.
0 commit comments