Promise.all result is treated as possibly undefined, widening mapped rows

已关闭
#3,080 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@alantriesagain 已经在做这个了。

开始于 2026年11月6日。

  • #3085 来自 @alantriesagain —— 未关闭
  • #3109 来自 @ctate —— 未关闭

评估

难度
4/5
预计耗时
3-5 天
新手友好度
47/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
领域
compilers

调研方向

Start with the optional-read analysis that assigns facts to Promise.all results, then inspect the TypeScript and JavaScript corpus cases async-early-return-promise-all.ts and async-early-return-promise-all.js. Compare their SC9001 failures with the reported passing cases 4948 and 4956, and check the Promise.allSettled behavior. Done means the reported Promise.all cases compile without the internal errors while Promise.allSettled remains conservative.

由索引模型根据 Issue 内容生成。

描述

Promise.all result is treated as possibly undefined, widening mapped rows

The optional-read analysis assumes that any Promise.all result can hold undefined. That fact lands on the element ABI of the array the result is stored in. After

rows = await Promise.all(rows.map((row) => load(row, includes)));

every array of that element type counted as possibly holding undefined. The map callback's parameter widened, the parameter of load widened with it, and an early return row made load return Promise<Row | undefined>. The callback's return became Promise<Row> | undefined, which nothing converts to, and the build failed with SC2003. In JavaScript the site was deferred, and a computed-key write through a loop binding over the result then failed validation.

A typed promise settles with a value of its own type. Every conversion into it checks the value, and the element ABI already records whether that type admits undefined. The Promise.all result therefore holds undefined only where an entry is a hole or undefined. Promise.allSettled keeps the conservative fact.

On 0.4.8, the TypeScript and JavaScript forms in our corpus (async-early-return-promise-all.ts and async-early-return-promise-all.js) still fail with SC9001 internal compiler errors around %recordValue and a bare null at row[field] = null. The separate JavaScript array and indexOf precision programs (4948 and 4956) now pass. The same failures reproduce on main (979a65246).

I opened #TBD with a patch for the Promise.all fact.

主要语言
TypeScript
星标
6.5k
派生
212
平均合并
13 小时 6 分钟
30 天内合并 PR
799

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

vercel-labs/scriptc 的其他 Issue

查看 vercel-labs/scriptc 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。