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 @@ -1869,12 +1869,8 @@ class PreCheckResultBuilderApplication : public ASTWalker {
1869
1869
E, DC, /* replaceInvalidRefsWithErrors=*/ true );
1870
1870
HasError |= transaction.hasErrors ();
1871
1871
1872
- if (!HasError) {
1873
- E->forEachChildExpr ([&](Expr *expr) {
1874
- HasError |= isa<ErrorExpr>(expr);
1875
- return HasError ? nullptr : expr;
1876
- });
1877
- }
1872
+ if (!HasError)
1873
+ HasError |= containsErrorExpr (E);
1878
1874
1879
1875
if (SuppressDiagnostics)
1880
1876
transaction.abort ();
@@ -1896,6 +1892,29 @@ class PreCheckResultBuilderApplication : public ASTWalker {
1896
1892
return std::make_pair (true , S);
1897
1893
}
1898
1894
1895
+ // / Check whether given expression (including single-statement
1896
+ // / closures) contains `ErrorExpr` as one of its sub-expressions.
1897
+ bool containsErrorExpr (Expr *expr) {
1898
+ bool hasError = false ;
1899
+
1900
+ expr->forEachChildExpr ([&](Expr *expr) -> Expr * {
1901
+ hasError |= isa<ErrorExpr>(expr);
1902
+ if (hasError)
1903
+ return nullptr ;
1904
+
1905
+ if (auto *closure = dyn_cast<ClosureExpr>(expr)) {
1906
+ if (shouldTypeCheckInEnclosingExpression (closure)) {
1907
+ hasError |= containsErrorExpr (closure->getSingleExpressionBody ());
1908
+ return hasError ? nullptr : expr;
1909
+ }
1910
+ }
1911
+
1912
+ return expr;
1913
+ });
1914
+
1915
+ return hasError;
1916
+ }
1917
+
1899
1918
// / Ignore patterns.
1900
1919
std::pair<bool , Pattern*> walkToPatternPre (Pattern *pat) override {
1901
1920
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