Skip to content

Saved parts testing#2060

Open
trefis wants to merge 3 commits into
mainfrom
saved-parts-testing
Open

Saved parts testing#2060
trefis wants to merge 3 commits into
mainfrom
saved-parts-testing

Conversation

@trefis
Copy link
Copy Markdown
Contributor

@trefis trefis commented Apr 17, 2026

Some investigations into merlin's saved parts motivated by the review of ocaml/ocaml#14241 .

A very short summary of a couple of long discussions:

  • merlin's handling of saved types in the absence of type errors is different from the typechecker and seemed potentially incorrect (?)
  • turns out if you try to mimick the type checker's behavior, you get unwanted nesting/duplication of the saved-parts, leading to a browse tree blowup (cf. 95ba06e) ; thanks to @let-def for pointing me in this direction, I'd have missed it

Some key points:

  • you have to look at the browse tree, because that's where merlin "unfolds" the saved parts, looking at the typedtree straight out of the typechecker wouldn't have shown the issue
  • this PR is for illustration purposes ... though if you want to be a bit defensive against future compiler updates, I suggest you reproduce and adapt the latest test (which shows when things blow up) for the other parts of the codebase which currently do not "save parts" on success.
  • I suspect the blow up wouldn't produce an observable difference in behavior with regular merlin commands (because most of them deduplicate nodes they receive from enclosing, the nodes they return, etc based on location) ... but it probably maybe could have a negative impact on performances? (notice the uncertainty)

@trefis
Copy link
Copy Markdown
Contributor Author

trefis commented Apr 17, 2026

Oh, one last thing: typemod tends to pass a ~save_part argument to with_saved_types ... does that lead to a blow up? Would there be an observable difference if it didn't?

I have neither checked nor thought hard about it. Have fun.

Copy link
Copy Markdown
Collaborator

@xvw xvw left a comment

Choose a reason for hiding this comment

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

this PR is for illustration purposes ... though if you want to be a bit defensive against future compiler updates, I suggest you reproduce and adapt the latest test (which shows when things blow up) for the other parts of the codebase which currently do not "save parts" on success.

We probably want to have a ticket to track this.

@voodoos
Copy link
Copy Markdown
Collaborator

voodoos commented May 4, 2026

There is a weird indentation issue in the test on the macos runner....

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.

3 participants