Skip to content
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

toplevel: find shorter path using the environment more directly #15

Open
wants to merge 5 commits into
base: genprintval-shorter-paths
Choose a base branch
from

Conversation

Octachron
Copy link

ping @gasche

This sub-PR implements my proposition for using the data available in Env to find shorter path for constructor, rather than doing multiple requests to the environment on successively longer guesses.

gasche and others added 5 commits October 9, 2024 10:01
@gasche
Copy link
Owner

gasche commented Oct 11, 2024

@Octachron your PR does not seem to behave as I would expect in the following case (I will add this to my own PR as a regression test):

(* Introduce Q with a Sub submodule *)
module Q = struct
  module Sub = struct type t = A end
end

(* open Q: Q.Sub.A can now be printed as Sub.A *)
open Q

(* shadow the Sub module:
   Sub.A is not a valid printing choice for Q.Sub.A anymore *)
module Sub = struct end
[%%expect {|
module Q : sig module Sub : sig type t = A end end
module Sub : sig end
|}]

(* Test the printing of Q.Sub.A *)
let it = Q.Sub.A
[%%expect {|
val it : Q.Sub.t = Q.Sub.A
|}]

With your PR, at the end I get Sub.A, while I expect Q.Sub.A.

@gasche
Copy link
Owner

gasche commented Oct 11, 2024

(Otherwise I find it hard to comment on the implementation because I don't really understand what is going on in TyCompTbl. I was surprised by the fact that it's a lot of code, while I expected it to be simpler than my own version. On the other hand, I suppose that it is more general and could be reused in other situations.)

@gasche gasche force-pushed the genprintval-shorter-paths branch 2 times, most recently from e15ef36 to 331d783 Compare October 14, 2024 13:58
@gasche gasche force-pushed the genprintval-shorter-paths branch 3 times, most recently from ccb069c to 09d6137 Compare December 16, 2024 20:41
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