Type errors print a type twice when it is reached through a module alias
メンテナーはふだん 1 日以内に返信
関連するプルリクエストがすでにマージされています。
- #9054 @cknitt による — マージ済み
評価
- 難易度
- 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時間 7分
- マージ済み PR(30日)
- 227
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rescript-lang/rescript のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 57/100
rescript-lang/rescript#9063 ·
メンテナーはふだん 1 日以内に返信
-
Formatter moves a line comment in a switch/if/loop operand into the block対応中かも @cknitt が今日担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
rescript-lang/rescript#9060 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
rescript-lang/rescript#9058 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 12/100
rescript-lang/rescript#9044 · コメント 1 件 · リアクション 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
rescript-lang/rescript#9006 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
rescript-lang/rescript の issue をすべて見る
似ている issue
-
JS_SetPropertyInternal2 loses the value when a lazy property on the prototype runs out of memoryオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
quickjs-ng/quickjs#1852 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
manuscript-lang/manuscript#1604 ·
メンテナーはふだん 1 日以内に返信
-
rust testing
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
NekomyaDev/nudge#275 ·
メンテナーはふだん 1 日以内に返信
-
jit: find libvx_cuda_dispatch next to vxc, as the runtime library is対応中かも @hiraditya が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
crash lld:COFF
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
llvm/llvm-project#235970 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信