Skip to content

Commit 88081a9

Browse files
authored
Merge pull request #85807 from allevato/more-json-ast-fixes-2
[ASTDumper] Fix malformed JSON for `async let _ = ...`.
2 parents 8dcc964 + 7ec3789 commit 88081a9

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/AST/ASTDumper.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,10 +1913,8 @@ namespace {
19131913
printFoot();
19141914
}
19151915
void visitAnyPattern(AnyPattern *P, Label label) {
1916-
if (P->isAsyncLet()) {
1917-
printCommon(P, "async_let ", label);
1918-
}
19191916
printCommon(P, "pattern_any", label);
1917+
printFlag(P->isAsyncLet(), "async_let", DeclModifierColor);
19201918
printFoot();
19211919
}
19221920
void visitTypedPattern(TypedPattern *P, Label label) {

test/Frontend/ast-dump-json-no-crash.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,3 +503,11 @@ func outerFn() {
503503
}
504504
innerFun(shouldRecurse: true)
505505
}
506+
507+
// Regression test: Discarded async lets were calling `printCommon` twice,
508+
// which resulted in invalid JSON (and not-so-great S-expression output)
509+
// either.
510+
func discardedAsyncLet() async {
511+
func someTask() async {}
512+
async let _ = someTask()
513+
}

0 commit comments

Comments
 (0)