-
Notifications
You must be signed in to change notification settings - Fork 563
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
Modules are permitted to re-export a type class and a type of the same name #3502
Milestone
Comments
Presumably then the plan is to fix this by disallowing it? That will be a breaking change, so shall we label it |
Sure thing |
joneshf
added a commit
to joneshf/purescript
that referenced
this issue
May 26, 2019
Within a module, we cannot define a class and a data type with the same name. The issue here is that we can define a class and a data type with the same name in different modules, then re-export them both from one module. We don't want to allow this behavior. We add a failing test to codify that this should not work.
joneshf
added a commit
to joneshf/purescript
that referenced
this issue
May 26, 2019
As mentioned in the previous commit (09bfea484ff6e0d77c028f11314763c794df8c47), we don't want to allow re-exporting a class and a type that have the same name. The changes here make that a reality. The majority of the tests are breaking because we're dependent on `purescript-typelevel-prelude` and it violates the changes here. See: purescript/purescript-typelevel-prelude#43 for more information.
joneshf
added a commit
to joneshf/purescript
that referenced
this issue
May 26, 2019
Before, we only had conflicting exports for the same types of things. Now that we disallow exports of different types, we'll want to be a bit more explict in what the problem is. Errors we'd get before looked like: ``` Export for type B.X conflicts with A.X ``` While that does convey what the problem is, we can do a bit better. Errors now look like: ``` Export for type B.X conflicts with type class A.X ```
joneshf
added a commit
to joneshf/purescript
that referenced
this issue
May 26, 2019
The changes to `purescript-typelevel-prelude` allow us to pass tests. The transitive dependency on `purescript-prelude` required an update.
hdgarrood
added a commit
to purescript/purescript-typelevel-prelude
that referenced
this issue
May 26, 2019
Refs #43, fixes #46. RowList-related types and classes have been removed from Type.Row and moved into Type.RowList, in order to prepare for an upcoming compiler change whereby a module will no longer be allowed to re-export both a type and a class of the same name; see purescript/purescript#3502
hdgarrood
pushed a commit
that referenced
this issue
May 26, 2019
* Add failing test for conflicting re-exports (#3502) Within a module, we cannot define a class and a data type with the same name. The issue here is that we can define a class and a data type with the same name in different modules, then re-export them both from one module. We don't want to allow this behavior. We add a failing test to codify that this should not work. * Disallow re-exporting same class/type name (#3502) As mentioned in the previous commit (09bfea484ff6e0d77c028f11314763c794df8c47), we don't want to allow re-exporting a class and a type that have the same name. The changes here make that a reality. The majority of the tests are breaking because we're dependent on `purescript-typelevel-prelude` and it violates the changes here. See: purescript/purescript-typelevel-prelude#43 for more information. * Print the type of the conflicting name (#3502) Before, we only had conflicting exports for the same types of things. Now that we disallow exports of different types, we'll want to be a bit more explict in what the problem is. Errors we'd get before looked like: ``` Export for type B.X conflicts with A.X ``` While that does convey what the problem is, we can do a bit better. Errors now look like: ``` Export for type B.X conflicts with type class A.X ``` * Update dependencies (#3502) The changes to `purescript-typelevel-prelude` allow us to pass tests. The transitive dependency on `purescript-prelude` required an update.
This was fixed by #3648. |
12 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently, it's possible to re-export a type and a type class of the same name from a module, even though it's not possible to define a type and a type class of the same name together in one module. For example,
There is an example of this in
purescript-typelevel-prelude
at version 3.0.0, where the moduleType.Row
re-exports the classCons
fromPrim.Row
as well as the typeCons
fromPrim.RowList
. At the moment, this is only a minor issue; as far as I'm aware, the only problem this can cause is that it can break anchor links in docs. However, if we ever want to do #1888 (which do still I think we should), I think we will need to make this an error.The text was updated successfully, but these errors were encountered: