microsoft / microsoft/TypeScript

Compiler crash: Debug Failure in visitEachChildOfIndexSignatureDeclaration

オープン
#63,230 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Bug Domain: Crashes
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
132

説明

### 🔎 Search Terms

typescript debug failure index signature
visitEachChildOfIndexSignatureDeclaration
typescript compiler crash decorator addInitializer
invalid index signature decorator
typescript Debug Failure index signature

### 🕗 Version & Regression Information

- This is the behavior in the version I tested (TypeScript 5.9.3). I reviewed the FAQ and did not find entries related to this compiler crash.

### ⏯ Playground Link

https://www.typescriptlang.org/play/?#code/FAMwrgdgxgLglgewgAgIYGd1wgcwCoCeADgKYAUIEAXMgGKSyIQA0yA+rAB40DCANhnQBZEjAAWCACYARElAQAnVDEU8kMEpxgBKAN7BkyA8j6jklAHKoAtiWQBedlwB0EGyWDGOMTs9STJAEkIOHhUPjgALxIFCgZ4JDJxOHQaXQBtAGsSAhp0GAVsHABdVlQIAgBfbWR9Q3rkZPR0y3dnFQBlAqKybWKHcwhnACNsSSSxFO0AbmNq42MFUTAFFHBoBJQAdyUiUgVkCZSacoJmZwvUBRxUtArkGpoANwQ4STr6+Qh0BFNnPgQODIAAMoAJMMhbOIpJD3MgACS6Vq2doILqFXC9SrA7TGQyUZxQcJ8I7oVgXPzXdC4wyVTyVIzAMGCZAACRIfABtWMX3yCjAsEUvX0cwWhgAAoIioRSMZJGiEFCiodtM9Xu88cheb8SP9AWQAERiDkAg005B0ypAA

### 💻 Code

```typescript
function assingType(fn: Function, _ctx: ClassMethodDecoratorContext){

let fnName = _ctx.name

_ctx.addInitializer(function(this: {[key: string], any}) { // here is my sintaxis error
// Invalid type annotation. The compiler should report a type error,
// but instead it crashes with "Debug Failure".
this[fnName.toString()] = fn.bind(this);
})

return function wrapper (this: any,...args: any ) : void{
console.log(`class method mame ${fnName.toString()}`)
fn.call(this, ...args)
}

}

class Hello {
constructor(){

}

@assingType
doSometing (): void{
console.log("hello")
}
}

```

### 🙁 Actual behavior

C:\Users\diazc\AppData\Roaming\npm\node_modules\typescript\lib\_tsc.js:123168
throw e;
^

Error: Debug Failure.
at visitEachChildOfIndexSignatureDeclaration (C:\Users\diazc\AppData\Roaming\npm\node_modules\typescript\lib\_tsc.js:90865:13)
at visitEachChild (C:\Users\diazc\AppData\Roaming\npm\node_modules\typescript\lib\_tsc.js:90721:33)
at visitEachChild2 (C:\Users\diazc\AppData\Roaming\npm\node_modules\typescript\lib\_tsc.js:133010:16)
at visitExistingNodeTreeSymbolsWorker (C:\Users\diazc\AppData\Roaming\npm\node_modules\typescript\lib\_tsc.js:132899:23)
at visitExistingNodeTreeSymbols (C:\Users\diazc\AppData\Roaming\npm\node_modules\typescript\lib\_tsc.js:132658:22)
at visitArrayWorker (C:\Users\diazc\AppData\Roaming\npm\node_modules\typescript\lib\_tsc.js:90535:49)
at visitNodes2 (C:\Users\diazc\AppData\Roaming\npm\node_modules\typescript\lib\_tsc.js:90506:19)
at visitEachChildOfTypeLiteralNode (C:\Users\diazc\AppData\Roaming\npm\node_modules\typescript\lib\_tsc.js:90911:7)
at visitEachChild (C:\Users\diazc\AppData\Roaming\npm\node_modules\typescript\lib\_tsc.js:90721:33)
at visitEachChild2 (C:\Users\diazc\AppData\Roaming\npm\node_modules\typescript\lib\_tsc.js:133010:16)

### 🙂 Expected behavior

The TypeScript compiler should not crash.

If the code is invalid, the compiler should emit a normal type error instead of throwing a "Debug Failure" during compilation.

### Additional information about the issue

This code does not crash in the TypeScript Playground. The Playground only reports normal type-checking errors.

However, when compiling locally with `tsc` (TypeScript 5.9.3), the compiler crashes with a "Debug Failure" during compilation.

A screenshot of the stack trace from the local `tsc` execution is attached.

Image

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

提供された TypeScript コードから始め、tsc 5.9.3 でローカルにクラッシュを再現してから、Playground の結果と比較します。visitEachChildOfIndexSignatureDeclaration からスタックを追跡し、無効なインデックスシグネチャ注釈を対象のケースとして使用します。コンパイラーが Debug Failure をスローする代わりに通常の型エラーを報告すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
compilers
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
48/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。