diff --git a/lib/AST/ASTDumper.cpp b/lib/AST/ASTDumper.cpp index ba07c0334e3..699b754721f 100644 --- a/lib/AST/ASTDumper.cpp +++ b/lib/AST/ASTDumper.cpp @@ -1913,10 +1913,8 @@ namespace { printFoot(); } void visitAnyPattern(AnyPattern *P, Label label) { - if (P->isAsyncLet()) { - printCommon(P, "async_let ", label); - } printCommon(P, "pattern_any", label); + printFlag(P->isAsyncLet(), "async_let", DeclModifierColor); printFoot(); } void visitTypedPattern(TypedPattern *P, Label label) { diff --git a/test/Frontend/ast-dump-json-no-crash.swift b/test/Frontend/ast-dump-json-no-crash.swift index 8fbbf46a4d1..e4db14fdc36 100644 --- a/test/Frontend/ast-dump-json-no-crash.swift +++ b/test/Frontend/ast-dump-json-no-crash.swift @@ -503,3 +503,11 @@ func outerFn() { } innerFun(shouldRecurse: true) } + +// Regression test: Discarded async lets were calling `printCommon` twice, +// which resulted in invalid JSON (and not-so-great S-expression output) +// either. +func discardedAsyncLet() async { + func someTask() async {} + async let _ = someTask() +}