Skip to content

Conversation

@Octachron
Copy link
Member

Currently, generating documentation from ml files

(* test.ml *)
let repeat x y = x ,y, x, y

makes odoc misprint equal type variables as distinc type variables:

val repeat : 'a -> 'b -> 'c * 'd * 'e * 'f

starting from OCaml 4.14 .

This issue stems from the uses of physical equalities on non-representative type expressions in the name map of the type expression loader of odoc. Consequently, different type nodes are attributed different names by odoc, even if they belong to the same class of equal-after-unification type nodes.

This issue typically doesn't arise when using mli files, because then we read source type expressions directly, without doing any unification (in most cases?).

This PR fixes this issue by ensuring that the naming maps only use representative type expressions.
Fortunately, this requires mostly tweaks to the Compat module.

Octachron and others added 3 commits July 25, 2024 13:36
Physical equality should not be used on type_expr to detect equality
of type variable node, since we are only interested by equality
up to equivalence in the union-find structure
Copy link
Collaborator

@Julow Julow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I've added a test case in Octachron#1 if you agree with it.

I think this deserves a change entry.

@Octachron
Copy link
Member Author

I have merged the test and added a changes entry, thanks !
(I wasn't sure were to add a test since it not strictly speaking a generator test).

Copy link
Collaborator

@Julow Julow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks !

@Julow Julow merged commit 8973686 into ocaml:master Jul 26, 2024
jonludlam pushed a commit that referenced this pull request Sep 13, 2024
jonludlam added a commit to jonludlam/opam-repository that referenced this pull request Sep 13, 2024
CHANGES:

### Fixed

- Fix missing katex headers (@panglesd, ocaml/odoc#1096)
- Allow `][` in code blocks, fixing issue ocaml/odoc#1137 (@Julow, ocaml/odoc#1149)
  This was interpreted as "code blocks with result", which now mandates a
  delimiter: `{delim@lang[ code ]delim[ result ]}`
- Fix misprinting of type variables from ml files for OCaml 4.14 and later
  (multiple occurences of the same type variable could be named differently)
  (@Octachron, ocaml/odoc#1173)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants