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(lib-collision): tolerate public_name collisions in different contexts #10549

Merged

Conversation

anmonteiro
Copy link
Collaborator

…ntexts

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
@anmonteiro anmonteiro force-pushed the anmonteiro/allow-public-name-collision branch from 2e21bd1 to bacf324 Compare May 19, 2024 23:17
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.

Thanks!

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

$ dune build
File "b/dune", line 3, characters 14-21:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This behavior is consistent with other cases I think (should be ok)

@@ -51,15 +46,9 @@ With some consumer
> EOF

$ cat > main.ml <<EOF
> let () = Foo.x
> let () = print_endline Foo.x
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did this modification change anything in the test behavior?

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 fixed the type errors in compilation

@anmonteiro anmonteiro merged commit e610e77 into ocaml:main May 25, 2024
28 checks passed
@anmonteiro anmonteiro deleted the anmonteiro/allow-public-name-collision branch May 25, 2024 23:01
@@ -473,15 +460,22 @@ module DB = struct
| Some lib ->
let name = Package.name pkg in
(name, Lib_entry.Library (Lib.Local.of_lib_exn lib)) :: acc)
| Library.T { visibility = Public pub; _ } ->
let+ lib = Lib.DB.find public_libs (Public_lib.name pub) in
| Library.T { visibility = Public pub; enabled_if; _ } ->
Copy link
Member

Choose a reason for hiding this comment

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

Why don't private libraries have an enabled_if check?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that's a good point. I'll make these changes shortly.

| Library.T { visibility = Public pub; _ } ->
let+ lib = Lib.DB.find public_libs (Public_lib.name pub) in
| Library.T { visibility = Public pub; enabled_if; _ } ->
let* lib = Lib.DB.find public_libs (Public_lib.name pub) in
Copy link
Member

Choose a reason for hiding this comment

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

You should use the id rather than the name for this check.

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 tried find_by_lib_id but I got a crash about adding a duplicate name in https://github.com/ocaml/dune/blob/main/src/dune_rules/install_rules.ml#L697

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'm not sure what that means yet.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, it's likely because it's finding the right lib now.

MA0010 pushed a commit to MA0010/dune that referenced this pull request Jun 5, 2024
…ntexts (ocaml#10549)

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
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.

None yet

3 participants