microsoft / microsoft/TypeScript

Crash: RangeError: Maximum call stack size exceeded during contextual typing of object literal with yield in computed property name

Đang mở
#62,941 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Bug Domain: check: Contextual Types Help Wanted
Ngôn ngữ chính
Go
Star
111k
Fork
14.3k
Merge trung bình
2 ngày 4 giờ
Pull request đã merge (30 ngày)
132

Mô tả

### 🔎 Search Terms

RangeError: Maximum call stack size exceeded

checkYieldExpression recursion

getContextualTypeForObjectLiteralElement crash

Computed property name generator yield

### 🕗 Version & Regression Information

Versions tested: 5.7.3, 5.8.3, 5.9.3, Nightly
Behavior: All tested versions crash.
Precondition: Only crashes when the variable has an explicit type annotation (e.g., : any).
Comparison: let x = { ... } (inference) does not crash; let x: any = { ... } (contextual typing) crashes.

### ⏯ Playground Link

https://www.typescriptlang.org/zh/play/?target=2&ts=6.0.0-dev.20251231#code/GYVwdgxgLglg9mAVAAgOYAoCUyDeAoZQ5AGwFMpkAPALgEMwBPZAXlwKI8QG0GZTiAJsgAMAXSxsOHAL7tC0gNx5pQA

### 💻 Code

```ts
function* g() {
// The explicit ': any' is required to trigger the crash
let x:any = {
*[yield 0]() {
}
};
}
```

### 🙁 Actual behavior

```
.\ts-versions\nightly\node_modules\.bin\tsc.cmd C:\Users\aw\Desktop\itr\result0\mutated\generatorTypeCheck43_mutated_iter7.ts
D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:123181
throw e;
^

RangeError: Maximum call stack size exceeded
at hasSyntacticModifier (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:16878:30)
at getFunctionFlags (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:15771:11)
at checkYieldExpression (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:80294:27)
at checkExpressionWorker (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:80953:16)
at checkExpression (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:80809:32)
at getContextualTypeForObjectLiteralElement (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:73061:28)
at getContextualTypeForObjectLiteralMethod (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:73044:12)
at getApparentTypeOfContextualType (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:73260:58)
at getContextualSignature (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:73692:18)
at getContextualSignatureForFunctionLikeDeclaration (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:73684:87)

Node.js v22.19.0
```

### 🙂 Expected behavior

The compiler should not crash.

### Additional information about the issue

_No response_

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với ví dụ TypeScript rút gọn và các đường dẫn của compiler được nêu trong stack trace: checkYieldExpression, getContextualTypeForObjectLiteralElement, getContextualTypeForObjectLiteralMethod và getContextualSignature. Chạy bản tái hiện với annotation any tường minh, sau đó so sánh với kiểu được suy luận. Hoàn tất khi compiler không báo stack overflow đối với trường hợp generator có computed property.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
typescript
Lĩnh vực
compilers
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.