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

Refactor typedtree traverse to use compiler traverse #1031

Merged

Conversation

panglesd
Copy link
Collaborator

This is hopefully less maintenance, increased compatibility, shorter code, and the guaranty that we don't miss any occurrence of some deeply nested core type (for instance) for source features such as #976.

@panglesd panglesd added the no changelog This pull request does not need a changelog entry label Oct 27, 2023
@panglesd panglesd force-pushed the cherry-picked-refactor-typedtree-traverse branch 3 times, most recently from 9d53add to bc94c52 Compare October 27, 2023 07:57
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.

Looks good! The code indeed looks much more maintainable.

I couldn't find new links but I noticed that this now generates more anchors (for example in structures passed as argument to functors).

@panglesd
Copy link
Collaborator Author

I noticed that this now generates more anchors

Could you give me an example? In particular, is the new anchor a "local anchor", or a "global anchor"?
I expect it to be a local anchors. The global anchors should be the same, but it is very possible that the old manual traverse was missing local anchors.

@Julow
Copy link
Collaborator

Julow commented Oct 27, 2023

By diffing the output of @docgen, I only see changes in local anchors. For example, in src/document/ML.ml there's new local anchors for close_tag_closed, etc..
Here's the observed diff: https://gist.github.com/Julow/230e1e240453137f8cbcc5072e75c47a

@panglesd
Copy link
Collaborator Author

panglesd commented Oct 27, 2023

Thanks. Indeed, two anchors for the same identifier are generated... let me investigate!

@panglesd
Copy link
Collaborator Author

The post-processing of source info is now more careful to not add two definition at the same place. In case of "conflicts", we use the "local anchor", which is more readable, rather than the def_%d anchor.

Copy link
Contributor

@gpetiot gpetiot left a comment

Choose a reason for hiding this comment

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

It looks good to me!

src/loader/typedtree_traverse.ml Show resolved Hide resolved
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.

Looks good :)
I love the new local_... anchors! Though, the diff is now too large to be inspected, I believe the code to be correct.

src/loader/typedtree_traverse.ml Show resolved Hide resolved
src/loader/implementation.ml Show resolved Hide resolved
src/loader/implementation.ml Outdated Show resolved Hide resolved
@panglesd
Copy link
Collaborator Author

While trying to add a comment as suggested in #1031 (comment), I realized that the code was not clear enough...

In 48f8f06 I tried to improve that. @Julow is it clearer like that?

@jonludlam
Copy link
Member

The post-processing of source info is now more careful to not add two definition at the same place. In case of "conflicts", we use the "local anchor", which is more readable, rather than the def_%d anchor.

Just want to check that that's not going to lead to broken links? As in, if something is linking here and we've dropped the def_... anchor in favour of the local one, won't that break the link?

@panglesd
Copy link
Collaborator Author

Just want to check that that's not going to lead to broken links? As in, if something is linking here and we've dropped the def_... anchor in favour of the local one, won't that break the link?

No, that's not going to lead to any dead link. All source ids are stored in a loc to id table, from which we generate both the links and the anchors.

@panglesd panglesd force-pushed the cherry-picked-refactor-typedtree-traverse branch from 4523140 to fbb69e2 Compare November 1, 2023 08:42
@jonludlam jonludlam force-pushed the cherry-picked-refactor-typedtree-traverse branch from fbb69e2 to 78cfd57 Compare November 7, 2023 14:18
@jonludlam
Copy link
Member

In it goes!

@jonludlam jonludlam merged commit 0b4a460 into ocaml:master Nov 7, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no changelog This pull request does not need a changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants