-
Notifications
You must be signed in to change notification settings - Fork 139
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
Inferred types cause unsoundness in the importing module (leaking False
)?
#2410
Comments
Ugh. I have a feeling this bug is because
IMO, the fix is to handle
In both the So we really need to either reject or replace-with-true. |
I don't know much about a typical workflow of a Haskell/LH programmer, but assuming that people start working on modules with everything exported by default, rejecting all the If resolving to Also, is there a reason to keep a |
You make a very good point -- maybe defaulting to TBH I cannot recall if the |
I agree that everything silent may be confusing. A warning for exported functions with inferred (and |
[This is for 9.10.1; I haven't checked earlier versions]
When I am trying to use type inference for top-level functions exported from the module, it seems that LH infers
False
/bottom that leaks into the importing module and makes all the checks pass.Here is an example:
Lib.hs
Main.hs
The compiler says
If I remove the inference annotation on
c5
, then I get an error forc7
inMain
as expected.Another option is to use a function instead of a constant, e.g. in Lib.hs, write
and then modify
c7
in Main.hs like this:Note that if
ispos
is not called, then I do get an error. That's why I suspect that it is a callispos 0
that introduces some kind ofFalse
into the context, whereas withc5
, such aFalse
is already in the context.And I'd guess that
False
gets inferred because there are no use sites ofc5
andispos
within Lib.hs.But! When I hover over types of
c5
andispos
in the produced HTML file, they are justInt
andInt -> Bool
. I don't see anyFalse
... I am puzzled :)UPD Replacing the hole in
c5
with an explicitFalse
causes a compilation errorThe text was updated successfully, but these errors were encountered: