Type errors print a type twice when it is reached through a module alias
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 70/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- ocaml
- 領域
- compilers
研究方向
Start in compiler/ml/printtyp.ml at same_path and read how it compares paths used by type_expansion and super_type_expansion; the issue points to alias normalization via Env.normalize_path. Check the type mismatch and coercion examples, then run the snapshot test GeneratorResumeTypeWidening mentioned in the issue. Done means aliased types print once, matching the output for the equivalent unaliased type.
由索引模型根據 Issue 內容生成。
描述
When a type is reached through a module alias, type errors print it twice, once as written and once as its "expansion", which prints identically. This hits every stdlib type used through Stdlib's aliases (Map.t, Generator.t, …).
Type mismatch
let f = (x: Map.t<string, int>): Map.t<string, string> => x
This has type: Map.t<string, int> (defined as Map.t<string, int>)
But it's expected to have type:
Map.t<string, string> (defined as Map.t<string, string>)
Coercion
let widen = (g: Generator.t<int, unit, [#X]>) => (g :> Generator.t<int, unit, [#X | #Y]>)
Type Generator.t<int, unit, [#X]> = Generator.t<int, unit, [#X]>
is not a subtype of
Generator.t<int, unit, [#X | #Y]> = Generator.t<int, unit, [#X | #Y]>
Expected: This has type: Map.t<string, int> and Type Generator.t<int, unit, [#X]> is not a subtype of Generator.t<int, unit, [#X | #Y]>, as printed when the type is written without the alias (Stdlib_Map.t<string, int>).
With a local alias the output is not identical but still says nothing, since an alias is the same module:
module Inner = {
type t<'a>
}
module A = Inner
let m = (x: A.t<[#X]>) => (x :> A.t<[#X | #Y]>)
Type A.t<[#X]> = Inner.t<[#X]> is not a subtype of
A.t<[#X | #Y]> = Inner.t<[#X | #Y]>
Likely cause
same_path in compiler/ml/printtyp.ml, which decides whether to print the expansion (type_expansion, super_type_expansion), compares the paths from best_type_path with Path.same. That doesn't normalize module aliases, so Stdlib.Map.t and its expansion Stdlib_Map.t count as different; the short-path printer then prints both as Map.t. Comparing the alias-normalized paths (Env.normalize_path) should fix it.
Found while adding a test for #8981, whose GeneratorResumeTypeWidening snapshot records the doubled output.
- 主要語言
- OCaml
- 星號
- 7.5k
- 分支
- 483
- 平均合併
- 20 小時 28 分鐘
- 30 天內合併 PR
- 201
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
rescript-lang/rescript 的其他 Issue
-
難度 5/5 一週以上 新手友好度 35/100
rescript-lang/rescript#9006 ·
維護者通常 1 天內回覆
-
難度 3/5 1-2 天 新手友好度 68/100
rescript-lang/rescript#8994 ·
維護者通常 1 天內回覆
-
@notUndefined in an interface is not checked against the implementation可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉
難度 4/5 3-5 天 新手友好度 35/100
rescript-lang/rescript#8964 · 1 則留言 ·
維護者通常 1 天內回覆
-
Have formatter insert newlines around multi-line expressions可能已有人在做 @rolandpeelen 於 1 天前認領。 未關閉
難度 4/5 3-5 天 新手友好度 25/100
rescript-lang/rescript#8960 ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 48/100
rescript-lang/rescript#8955 ·
維護者通常 1 天內回覆
查看 rescript-lang/rescript 的全部 Issue
相似的 Issue
-
Slang input: int8_t4_packed and uint8_t4_packed are copied into CrossGL可能已有人在做 @ninglinLiu 今天認領。 未關閉area:frontend backend:slang bug direction:input
難度 2/5 1-3 小時 新手友好度 70/100
維護者通常 1 天內回覆
-
clang:frontend code-cleanup HLSL
難度 2/5 1-3 小時 新手友好度 74/100
llvm/llvm-project#235100 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
paritytech/polkavm#442 ·
-
policy-compiler
難度 2/5 1-3 小時 新手友好度 67/100
aranya-project/aranya-core#861 · 3 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 83/100
objectionary/phino#2075 ·
維護者通常 1 天內回覆