[ASTDumper] Fix malformed JSON for async let _ = ....

By calling `printCommon` twice, this inserts a JSON object into
another JSON object without a key. This asserts inside LLVM's
JSON helper, but only if the compiler is built with assertions
enabled (which Xcode's compiler doesn't).

This also fixes the S-expression version, which is similarly busted:

```
(pattern_entry
  (async_let  type="Int"              (pattern_any type="Int")
  (original_init=call_expr type="Int" ...
```
This commit is contained in:
Tony Allevato
2025-12-02 15:59:54 -05:00
parent a437c6d6f6
commit 7ec3789cf7
2 changed files with 9 additions and 3 deletions

View File

@@ -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) {

View File

@@ -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()
}