microsoft / microsoft/TypeScript
Crash: RangeError: Maximum call stack size exceeded in getNameOfSymbolAsWritten via recursive conditional ReturnType
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
### 🔎 Search Terms
RangeError: Maximum call stack size exceeded
getNameOfSymbolAsWritten crash
symbolToTypeNode recursion
ReturnType indexed access crash
### 🕗 Version & Regression Information
Versions tested: 5.7.3, 5.8.3, 5.9.3, Nightly, TS7.
### ⏯ Playground Link
https://www.typescriptlang.org/zh/play/?target=7&ts=6.0.0-dev.20260319#code/GYVwdgxgLglg9mABBANggpgCgJQC5EA8AKgHyZwBGAVvkdogLwmJGLoAeU6YAJgM6IAhmACeiAPyIASuiggATmCIiADugJRV6OMGRow6EgG0ADAF1E+EwG4gA
### 💻 Code
```ts
function clone(): (obj: T) => T extends any ? ReturnType[0] : 0;
```
### 🙁 Actual behavior
```
node built/local/tsc.js -noEmit functionOnlyHasThrow_filled_2_unvalidated_mutated_batch6.ts
D:\github\TypeScript\built\local\_tsc.js:123721
throw e;
^
RangeError: Maximum call stack size exceeded
at getTextOfNodeFromSourceText (D:\github\TypeScript\built\local\_tsc.js:13034:37)
at getSourceTextOfNodeFromSourceFile (D:\github\TypeScript\built\local\_tsc.js:13017:10)
at getTextOfNode (D:\github\TypeScript\built\local\_tsc.js:13045:10)
at declarationNameToString (D:\github\TypeScript\built\local\_tsc.js:13854:60)
at getNameOfSymbolAsWritten (D:\github\TypeScript\built\local\_tsc.js:55596:16)
at createAccessFromSymbolChain (D:\github\TypeScript\built\local\_tsc.js:53234:25)
at symbolToTypeNode (D:\github\TypeScript\built\local\_tsc.js:53211:26)
at typeToTypeNodeWorker (D:\github\TypeScript\built\local\_tsc.js:51561:18)
at typeToTypeNodeHelper (D:\github\TypeScript\built\local\_tsc.js:51342:24)
at conditionalTypeToTypeNode (D:\github\TypeScript\built\local\_tsc.js:51640:31)
Node.js v22.19.0
```
### 🙂 Expected behavior
The compiler should not crash.
### Additional information about the issue
_No response_
コントリビューションガイド
調査の方向性
リンクされた Playground の例を使うか、報告された tsc コマンドを functionOnlyHasThrow_filled_2_unvalidated_mutated_batch6.ts に対して実行して、クラッシュを再現してください。報告されたパスを conditionalTypeToTypeNode、typeToTypeNodeWorker、symbolToTypeNode、getNameOfSymbolAsWritten を通して追跡し、この再帰的な ReturnType のケースがクラッシュせずに完了することを示す回帰テストを追加してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 48/100