microsoft / microsoft/TypeScript
Crash: optional chain + tagged template panics the optional-chain transform
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
🔎 Search Terms
flattenChain tagged template, KindTaggedTemplateExpression, "Unhandled case in Node.Expression", "isOptionalChain", optional chain tagged template crash, e?.``(
🕗 Version & Regression Information
- This is a crash
- This is the behavior in every version I tried: TypeScript 6.0.3 (JS) and 7.1.0-dev (
main, Go) - I have reviewed the FAQ for entries about optional chaining and tagged templates. Those entries do not cover this compiler crash.
⏯ Playground Link
Not useful here. The crash needs ES2020 optional-chain emit. Use the CLI command below.
💻 Code
e?.``(
🙁 Actual behavior
panic: Unhandled case in Node.Expression: KindTaggedTemplateExpression [recovered, repanicked]
goroutine 13 [running]:
sync.(*WaitGroup).Go.func1.1()
sync/waitgroup.go:251 +0x48
panic({0x10417d8e0?, 0x2b3e77a92750?})
runtime/panic.go:860 +0x12c
github.com/microsoft/TypeScript/tsc/internal/ast.(*Node).Expression(...)
github.com/microsoft/TypeScript/tsc/internal/ast/ast.go:383 +0x718
github.com/microsoft/TypeScript/tsc/internal/transformers/estransforms.flattenChain(...)
github.com/microsoft/TypeScript/tsc/internal/transformers/estransforms/optionalchain.go:143 +0x1c4
github.com/microsoft/TypeScript/tsc/internal/transformers/estransforms.(*optionalChainTransformer).visitOptionalExpression(...)
github.com/microsoft/TypeScript/tsc/internal/transformers/estransforms/optionalchain.go:151 +0x38
github.com/microsoft/TypeScript/tsc/internal/transformers/estransforms.(*optionalChainTransformer).visitCallExpression(...)
github.com/microsoft/TypeScript/tsc/internal/transformers/estransforms/optionalchain.go:37 +0x190
github.com/microsoft/TypeScript/tsc/internal/transformers/estransforms.(*optionalChainTransformer).visit(...)
github.com/microsoft/TypeScript/tsc/internal/transformers/estransforms/optionalchain.go:20 +0xd0
github.com/microsoft/TypeScript/tsc/internal/ast.(*NodeVisitor).VisitNode(...)
github.com/microsoft/TypeScript/tsc/internal/ast/visitor.go:51 +0x30
github.com/microsoft/TypeScript/tsc/internal/ast.(*ExpressionStatement).VisitEachChild(...)
github.com/microsoft/TypeScript/tsc/internal/ast/ast_generated.go:1592 +0x30
... 74 lines truncated ...
github.com/microsoft/TypeScript/tsc/internal/compiler.(*emitter).emitJSFile(...)
github.com/microsoft/TypeScript/tsc/internal/compiler/emitter.go:200 +0x198
github.com/microsoft/TypeScript/tsc/internal/compiler.(*emitter).emit(...)
github.com/microsoft/TypeScript/tsc/internal/compiler/emitter.go:50 +0xec
github.com/microsoft/TypeScript/tsc/internal/compiler.(*Program).Emit.func2()
github.com/microsoft/TypeScript/tsc/internal/compiler/program.go:1851 +0x1c0
🙂 Expected behavior
The compiler should not crash 😄
Additional information about the issue
Disclosure: This crash was found with a custom mutation fuzzer and AI assistance (Kimi K3). The input was minimized and then verified by hand against TypeScript 7.1.0-dev (main) and TypeScript 6.0.3.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
tsc/internal/transformers/estransforms/optionalchain.go から始め、特に flattenChain と visitOptionalExpression を確認してから、tsc/internal/ast/ast.go の Node.Expression の処理を調べます。最小化した例 e?.``( を、ES2020 の optional-chain emit を指定して CLI 経由で実行します。この入力でコンパイラーが panic しなくなれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- go, typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 活発
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 76/100