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

fix: redirect deprecated libraries resolution to the public lib DB #10354

Conversation

anmonteiro
Copy link
Collaborator

@anmonteiro anmonteiro commented Apr 1, 2024

addresses this comment

@@ -23,12 +23,12 @@ different folders.
Without any consumers of the libraries

$ dune build
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this error becomes better: we now use the loc for the (public_name ..) field, which is the actual conflict.

@anmonteiro anmonteiro force-pushed the anmonteiro/deprecated-name-redirect-to-public branch from 7947efa to dc6ced7 Compare April 2, 2024 00:39
Copy link
Collaborator

@jchavarri jchavarri left a comment

Choose a reason for hiding this comment

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

I'm afraid I don't fully understand what the change in redirection to parent is fixing (besides the better locations in errors mentioned). But otherwise lgtm.

@@ -85,13 +85,13 @@ module DB = struct
else Lib.DB.Resolve_result.not_found
| Found lib -> Memo.return (Lib.DB.Resolve_result.found lib)
| Deprecated_library_name lib ->
Memo.return (Lib.DB.Resolve_result.redirect_in_the_same_db lib)
Memo.return (Lib.DB.Resolve_result.redirect parent lib)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this change unlocks new possibilities? I can see that the behavior exercised in features.t test suite isn't modified. Maybe there's some case with some deprecation of a library into a lib only available in the public lib db that would be affected by this change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I believe this change is just saving us 1 redirect, because the new public name will exist in the public libs DB. We'd redirect anyway at resolution time (following 2 redirects, now just 1)

@anmonteiro
Copy link
Collaborator Author

Isn't this constructor also used for redirecting public names to private names?

I think this might be true. We may have to specify whether we're redirecting to a name or a library ID.

@rgrinberg
Copy link
Member

rgrinberg commented Apr 2, 2024

Just to make sure we're on the same page, I think we need two constructors:

  1. Redirect of Lib_name.t * DB.t used for implementing (deprecated_library_stanza ..). The target db here should be the public db
  2. Redirect of Lib_id.t used for implementing public to private redirects.

@anmonteiro
Copy link
Collaborator Author

anmonteiro commented Apr 2, 2024

@rgrinberg I need to dig deeper into the redirect business, but we may have that already? Lib.DB.Resolve_result.redirect takes a DB and a Lib_id.t

EDIT: 🤦 except I changed that in this PR. I see what you mean.

@anmonteiro anmonteiro force-pushed the anmonteiro/deprecated-name-redirect-to-public branch from dc6ced7 to 3b1fea4 Compare April 2, 2024 21:42
@anmonteiro
Copy link
Collaborator Author

OK I added a new Redirect_to_lib_id constructor that handles the redirection for local stanzas.

I also added visibility in Lib_id to get the "best loc" for a stanza. This way we make sure to keep showing the correct loc for the public name clash case in tests.

@@ -18,7 +23,7 @@ module Local = struct
| x -> x
;;
Copy link
Member

Choose a reason for hiding this comment

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

I missed this from before, but this seems wrong. How is the comparison function ignoring the other elements?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My thought was that, since this refers to Local library IDs, the loc would be more than enough to distinguish different lib_ids.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The only field we're not comparing is enabled_if. We could, but I couldn't come up with a compare function for Blang.t -- there's only Blang.equal.

Copy link
Member

Choose a reason for hiding this comment

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

My thought was that, since this refers to Local library IDs, the loc would be more than enough to distinguish different lib_ids.

In that case, I would drop the enabled_if from the id as well.

@@ -1,9 +1,14 @@
open Import

type visibility =
Copy link
Member

Choose a reason for hiding this comment

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

Could you split this change into a separate PR? I think adding not strictly necessary fields to Lib_id isn't something we should do lightly.

@@ -85,13 +85,13 @@ module DB = struct
else Lib.DB.Resolve_result.not_found
| Found lib -> Memo.return (Lib.DB.Resolve_result.found lib)
| Deprecated_library_name lib ->
Memo.return (Lib.DB.Resolve_result.redirect_in_the_same_db lib)
Memo.return (Lib.DB.Resolve_result.redirect parent lib)
Copy link
Member

Choose a reason for hiding this comment

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

Is parent always the public library database here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes. I'll move these functions more closely together and make that explicit in a comment

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it adds a bit of whitespace diff noise, but I did the above in 3e73083

@anmonteiro anmonteiro force-pushed the anmonteiro/deprecated-name-redirect-to-public branch from ec08819 to 6395ddd Compare April 3, 2024 21:32
let create_db_from_stanzas =
(* Here, [parent] is always the public_libs DB. Check the call to
[create_db_from_stanzas] below. *)
let resolve_found_or_redirect ~parent fr =
Copy link
Member

Choose a reason for hiding this comment

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

How about just rename ~parent to ~public_db then?

@anmonteiro anmonteiro force-pushed the anmonteiro/deprecated-name-redirect-to-public branch from 613e494 to 6303565 Compare April 4, 2024 18:21
@anmonteiro anmonteiro merged commit c6a0a69 into ocaml:main Apr 4, 2024
26 of 27 checks passed
@anmonteiro anmonteiro deleted the anmonteiro/deprecated-name-redirect-to-public branch April 4, 2024 18: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.

3 participants