microsoft / microsoft/TypeScript
Crash: when inferring from a tuple with middle rest elements and trailing variadic elements
还没有人认领这个 Issue。
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.3k
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 132
描述
### 🔎 Search Terms
Internal Error: Debug Failure
Variadic tuple types crash
infer rest elements crash
tuple mapping crash
### 🕗 Version & Regression Information
Versions tested: 5.7.3, 5.8.3, 5.9.3, Nightly
### ⏯ Playground Link
https://www.typescriptlang.org/zh/play/?target=7&noEmit=true&ts=6.0.0-dev.20260117#code/PTAEAEGcBcCcEsDG0Bco4FcCmAoEEA7AewFEBbeVdWbPMWLAB1iNAGIBWARi4GYAOHNACejLKADKGAEYAVDIwBMAJSwwAggQAms2AEN4AG3gEA5gDU9CPVqSKAPLNBYAHtCzbIoDAQDWxAHcCAG0AXQA+UABeUCdXd09QYJxQVNAAOkyAChMAMyxYUABhAEowgBoUtMz0vILQACFnNw8tL2C9AmFyzu7EfUgAC1CcUNAq1IB+JKLymoaxidA0AiwANwKAbhwhUXEpOQUVNWhNHX0jEwsreBs7WRPoyRl5JVUNbV0DYzNLa1tEA5gjU9GgAAwVaRoLjlRBoRQRbZAA
### 💻 Code
```ts
// repro #51138
type SubTup2RestAndTrailingVariadic2 = T extends [
...(infer C)[],
...infer B extends [any,any,crash]
]
? [C,...B]
: never;
type SubTup2RestAndTrailingVariadic2Test = SubTup2RestAndTrailingVariadic2<[...a: 0[],b: 1,c: 2]>;
```
### 🙁 Actual behavior
```
.\ts-versions\nightly\node_modules\.bin\tsc.cmd .\inferTypesWithFixedTupleExtendsAtVariadicPosition_m.ts
D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:123178
throw e;
^
TypeError: Cannot read properties of undefined (reading 'aliasSymbol')
at inferFromTypes (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:68512:18)
at inferFromObjectTypes (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:68994:21)
at invokeOnce (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:68704:9)
at inferFromTypes (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:68666:11)
at inferTypes (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:68500:5)
at getConditionalType (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:62537:11)
at getConditionalTypeInstantiation (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:63526:305)
at instantiateTypeWorker (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:63629:14)
at instantiateTypeWithAlias (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:63566:20)
at getTypeAliasInstantiation (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:60132:52)
Node.js v22.19.0
```
### 🙂 Expected behavior
The compiler should report a syntax error and not crash.
### Additional information about the issue
_No response_
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
先从 Playground 复现和提供的元组推断示例开始,然后跟踪编译器调用栈,从 inferFromTypes 经过 inferFromObjectTypes 到 getConditionalType。使用列出的 TypeScript 版本复现崩溃,并确定相关的编译器回归测试位置。当此输入报告语法错误而不是抛出内部 TypeError 时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- compilers
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100