Type errors print a type twice when it is reached through a module alias
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 70/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- ocaml
- Domaine
- compilers
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- OCaml
- Étoiles
- 7.5k
- Forks
- 483
- Merge moyen
- 19 h 35 min
- PR mergées (30 j)
- 208
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de rescript-lang/rescript
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
rescript-lang/rescript#9037 ·
Les mainteneurs répondent en général sous 1 jour
-
Per-constructor @unboxed is not compared across interfaces or coercionsPeut-être pris @cknitt l’a pris aujourd’hui. Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 25/100
rescript-lang/rescript#9038 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
rescript-lang/rescript#9006 · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 3/5 1-2 jours Accessibilité débutants 68/100
rescript-lang/rescript#8994 ·
Les mainteneurs répondent en général sous 1 jour
-
@notUndefined in an interface is not checked against the implementationPeut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
rescript-lang/rescript#8964 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de rescript-lang/rescript
Issues similaires
-
Slang input: int8_t4_packed and uint8_t4_packed are copied into CrossGLPeut-être pris @ninglinLiu l’a pris il y a 1 jour. Ouvertearea:frontend backend:slang bug direction:input
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
CrossGL/crosstl#2801 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
lane:parser todo:ticket
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
Les mainteneurs répondent en général sous 1 jour
-
Decompiler: convertCharRef() in xml.y overflows its int4 accumulator on long character referencesPeut-être pris @kaayzouee l’a pris il y a 1 jour. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
NationalSecurityAgency/ghidra#10009 ·
Les mainteneurs répondent en général sous 2 jours
-
[Bug] tree-sitter-bash parses `$_` / `${_}` as variable_name instead of special_variable_nameOuverte
Difficulté 2/5 Moins d'une heure Accessibilité débutants 85/100
MoonshotAI/kimi-code#4367 ·
Les mainteneurs répondent en général sous 1 jour
-
clang:frontend code-cleanup HLSL
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
llvm/llvm-project#235100 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour