microsoft / microsoft/TypeScript
Crash: RangeError: Maximum call stack size exceeded during contextual typing of object literal with yield in computed property name
还没有人认领这个 Issue。
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.3k
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 132
描述
🔎 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
💻 Code
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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从精简的 TypeScript 示例以及 stack trace 中提到的编译器路径开始:checkYieldExpression、getContextualTypeForObjectLiteralElement、getContextualTypeForObjectLiteralMethod 和 getContextualSignature。使用显式的 any 注解运行复现,然后将其与推断类型进行比较。当编译器针对带计算属性的 generator 情况不再报告 stack overflow 时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- compilers
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 45/100