-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression in printing of shadowed predef types #12738
Comments
I can reproduce with my 5.1.0 toplevel, but only if |
Thanks for opening the issue, I agree that this is a regression for |
Something else appears to be going on here, beyond just
I haven't yet been able to get this down to a smaller reproduction. |
I can reproduce this when the declaration comes from another compilation unit. $ cd /tmp
$ echo "type nonrec unit = unit" > u.ml
$ ocamlc u.ml
$ ocaml -short-paths u.cmo
# open U;;
# ();;
- : unit/2 = () |
This being said: we have been in discussion for years about replacing the current short-paths implementation with a better one that is in Merlin ( #6600 (comment) ). Given the lack of availability of anyone to work on this, @Octachron has volunteered but he is busy with other things and hasn't come around to it yet. If I was @Octachron I would ignore this issue until the Merlin implementation of -short-paths has been looked at for real (it may even be that it fixes the issue by itself). Fixing minor issues in the legacy (upstream) implementation is probably a waste of time. |
Out of curiosity I tried to write a test in Merlin for 5.1 and I think I successfully failed to reproduce the issue: $ cat >u.ml <<'EOF'
> type nonrec unit = unit
> EOF
$ $OCAMLC -c u.ml
$ cat >main.ml <<'EOF'
> open U;;
> ();;
> EOF
$ $MERLIN single type-enclosing -position 2:1 -filename main.ml <main.ml |
> jq '.value[0].type'
"unit" I always looked at |
(It's likely this is more widespread than predef types, but I can only easily come up with examples that use predef types.)
#11515 makes the type printer more predictable, but I find at least one surprising change in the type printer. For an example, run
ocamlc -i
on a .ml file containing this program:Prior to that PR, the output was:
Following that PR, the output is:
That is,
unit/2
is printed for the predef unit type, even thoughunit
is a less confusing way to name it.This is problematic for the
Base
opam package, as it exports aliasestype unit = Unit.t
frombase.ml
so that it's able to add ppx derivers to those declarations. (Unit.t
is defined asunit
.) The worse printing is currently exhibited in e.g. utop for 5.1:The text was updated successfully, but these errors were encountered: