You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Type errors print a type twice when it is reached through a module alias #8997
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, …).
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
letwiden= (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:
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.
Activity