-
Notifications
You must be signed in to change notification settings - Fork 662
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
Type-checking bug: comparable vs. number #1270
Comments
It's possible that this is somehow the same bug, or has the same root cause, as #1268. |
What should happen is that I think the larger problem is that we have these three not-quite-type-classes hacked into the language, and so edge cases like this one arise. It might have to wait until implicit parameters or whatever not-type-classes language feature comes along. That is, even if you manage to fix this bug without causing regressions, it might not be worth it if something big comes along in 0.19. |
For a start, I'd like to know whether @evancz agrees this is a bug. |
I think so. |
Centralizing into #1373, will track from there. |
The new combineRigidSupers function makes sure that the rigid variable always wins and that the rigid variable is a subset of the flex variable. There was also a bug in unifyRigid where the rigid variable would not win! The flex one would win. This accounted for some fraction of the bugs as well. I also try to avoid allocating new rigid content in unifyRigid to maybe make things a bit faster. Fixes #1268 Fixes #1270 Fixes #1281 Fixes #1316 Fixes #1422 Fixes #1581
Short version:
Should the following program type-check?
I don't think so, but the current compiler accepts that program.
Long version:
If I have a module
B
defining and exporting some functionf : comparable -> comparable
, should I be able to use it as follows in another module?I think so. After all,
'a'
is aChar
, and typeChar
iscomparable
, so'a'
should be a valid input for any function of typecomparable -> comparable
. However, the following module breaks that expectation:And down goes separate compilation. (Module
B
on its own compiles, so the compiler asserts that thef
in there really has typecomparable -> comparable
. ModuleA
should compile under the assumption thatf
has typecomparable -> comparable
. But modulesA
andB
together do not compile.)The text was updated successfully, but these errors were encountered: