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

Warn when trying to reference types in hidden modules #1940

Merged

Conversation

voughtdq
Copy link
Contributor

Closes #1932
When a module is hidden, its types will also be hidden. We check for two conditions and warn the user if both are met:

  • The module defining the type is hidden
  • The type itself is hidden If the type is undefined, the standard warning is displayed instead

It does not seem possible to do this check for Erlang modules.

Closes elixir-lang#1932
When a module is hidden, its types will also be hidden. We check for two
conditions and warn the user if both are met:
 - The module defining the type is hidden
 - The type itself is hidden
If the type is undefined, the standard warning is displayed instead.
Copy link
Member

@josevalim josevalim left a comment

Choose a reason for hiding this comment

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

This looks good to me but I have a feeling this was tried before and we reverted it for some reason. I will let @wojtekmach merge it accordingly.

@wojtekmach wojtekmach self-assigned this Aug 15, 2024
@wojtekmach wojtekmach merged commit 181d157 into elixir-lang:main Aug 15, 2024
5 checks passed
@wojtekmach
Copy link
Member

@josevalim we were already warning under these circumstances. This PR improves the error message!

@voughtdq thank you!

{{:type, AutolinkTest.Foo, :bad, 0}, :hidden}
{{:type, AutolinkTest.Foo, :bad, 0}, :hidden},
{{:module, AutoLinkTest.Hidden}, :hidden},
{{:type, AutoLinkTest.Hidden, :my_type, 0}, :hidden}
Copy link
Member

Choose a reason for hiding this comment

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

note to self: The testing setup is not fantastic. I don't know off the top of my head whether here :hidden is supposed to reflect the type is hidden or the type is (so to speak) public but because it is in hidden module it ends up hidden. This is an implementation detail.

A more robust way to test this would be more end-to-end:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

More explicit warning when type not visible because module is not visible
3 participants