Diagnostics: inline-record mutability coercion gives no reason, and `throw` in `finally` warns about unreachable code
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 38/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- ocaml
调研方向
The throw-in-finally case points to compiler/ml/typecore.ml around lines 2920-2922, where the finally block is typed as a statement; check how warning 21 is raised for non-returning statements. The inline-record coercion error is reached through a subtype path the payload does not name, so locate it by searching for the existing plain-record mutability explanation and compare the two. Run the two snippets from the issue to confirm the wrong output, and count done as the mutable-field explanation appearing for inline records and warning 21 no longer firing for throw in finally.
由索引模型根据 Issue 内容生成。
描述
Found by differential semantic drift analysis from b123b7c3 to c10223e8.
What is broken
-
Coercion into an inline record with a mutable field gives no reason (#9086). The coercion is now rejected, correctly:
type v1 = A({x: float}) type v2 = A({mutable x: float}) let a: v1 = A({x: 0.}) let b = (a :> v2)The error is only
Type v1 is not a subtype of v2. For a field of a plain record type ({r: r1}into{r: r2}) the error explains: "The field x is mutable in record r2, but not in record r1. A coercion can't make a field writable." -
throwinfinallygives warning 21 (#8931):exception B let k = () => try { 1 } finally { throw(B) }Warning 21: "This statement does not continue execution; following code is unreachable." No code follows the
throw; the generated JavaScript is correct. The finally block is typed as a statement (typecore.mlL2920-L2922), and a non-returning statement triggers this warning.
Possible cause (speculation only)
The inline-record path reports the subtype failure before reaching the field comparison that produces the explanation for plain records.
🤖 Generated with Claude Code
- 主要语言
- OCaml
- 星标
- 7.5k
- 派生
- 484
- 平均合并
- 16 小时 57 分钟
- 30 天内合并 PR
- 258
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
rescript-lang/rescript 的其他 Issue
-
Exception analysis does not know the Temporal `fromStringOrThrow` functions可能已有人在做 @cknitt 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
rescript-lang/rescript#9182 ·
维护者通常 1 天内回复
-
await in a functor body compiles to invalid JavaScript可能已有人在做 @mununki 今天认领。 未关闭
难度 4/5 3-5 天 新手友好度 25/100
rescript-lang/rescript#9219 ·
维护者通常 1 天内回复
-
`(() :> string)` compiles, and other coercions and variant spreads treat `bool` and `unit` as variants可能已有人在做 @mununki 今天认领。 未关闭
难度 4/5 3-5 天 新手友好度 35/100
rescript-lang/rescript#9216 ·
维护者通常 1 天内回复
-
A polymorphic variant argument of an external is evaluated twice, or inside a generated function可能已有人在做 @mununki 今天认领。 未关闭
难度 4/5 3-5 天 新手友好度 20/100
rescript-lang/rescript#9215 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
rescript-lang/rescript#9212 ·
维护者通常 1 天内回复
查看 rescript-lang/rescript 的全部 Issue
相似的 Issue
-
bug stdlib
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
0.kind: enhancement 9.needs: package (update)
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
S3: friction & debt ws:tooling
难度 2/5 1-3 小时 新手友好度 82/100
MedakaLang/medaka#4865 ·
维护者通常 1 天内回复
-
subsystem: saw-core type: bug
难度 2/5 1-3 小时 新手友好度 65/100
GaloisInc/saw-script#3516 ·
维护者通常 1 天内回复
-
Bug: the Atlas reports the five injected `$` helpers as unknown identifiers, including in the default scaffold可能已有人在做 @ShahadatTest 今天认领。 未关闭bug Compiler difficulty:easy good first issue help wanted Tooling
难度 2/5 1-3 小时 新手友好度 82/100
Avenx-JS/avenx-js#1615 · 1 条评论 ·
维护者通常 1 天内回复