-
-
Notifications
You must be signed in to change notification settings - Fork 370
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 type of print
using function is surprising
#806
Comments
If you add an argument |
Ah yea, good idea - it does indeed work if I write hello a = print a |
Note that I don't get this bug. If I write:
Then I get the warning:
And that warning prevents it from detecting an incorrect type signature. If I hover over the What did you do to manage to persuade it to get as far as it did? Were there any errors present? |
There were errors, but my editor (Emacs) happily showed me a code action on
hello to add a type signature. No extra convincing required
…On Wed, 11 Dec 2019, 8:45 pm Neil Mitchell, ***@***.***> wrote:
Note that I don't get this bug. If I write:
hello = print
Then I get the warning:
• Ambiguous type variable ‘a0’ arising from a use of ‘print’
prevents the constraint ‘(Show a0)’ from being solved.
Relevant bindings include
hello :: a0 -> IO () (bound at C:\Neil\temp\IDE.hs:3:1)
Probable fix: use a type annotation to specify what ‘a0’ should be.
These potential instances exist:
instance Show Ordering -- Defined in ‘GHC.Show’
instance Show Integer -- Defined in ‘GHC.Show’
instance Show a => Show (Maybe a) -- Defined in ‘GHC.Show’
...plus 22 others
...plus 12 instances involving out-of-scope types
(use -fprint-potential-instances to see them all)
• In the expression: print
In an equation for ‘hello’: hello = print
And that warning prevents it from detecting an incorrect type signature.
If I hover over the print it suggests Any -> IO () as the type, but
that's not unreasonable as the thing has failed to type check, so the fact
it displays anything is moderately surprising.
What did you do to manage to persuade it to get as far as it did? Were
there any errors present?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://github.com/digital-asset/ghcide/issues/228?email_source=notifications&email_token=AAAFDDQMVGDE7GLLYOQGQCLQYFGM7A5CNFSM4JZBRRZKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGUQJYY#issuecomment-564724963>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAFDDWIAAXDWGNEKBCUZJTQYFGM7ANCNFSM4JZBRRZA>
.
|
I was on GHC 8.6.5, what were you on? My understanding from the diagnostics I saw was that GHC wasn't giving the top-signature warning. |
This would have been GHC 8.8.1. Anything I can do to provide more info?
…On Wed, 11 Dec 2019, 10:01 pm Neil Mitchell, ***@***.***> wrote:
I was on GHC 8.6.5, what were you on? My understanding from the
diagnostics I saw was that GHC wasn't giving the top-signature warning.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://github.com/digital-asset/ghcide/issues/228?email_source=notifications&email_token=AAAFDDXUD5UFUW4IXQP7H53QYFPL3A5CNFSM4JZBRRZKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGUXFTA#issuecomment-564753100>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAFDDRJ55G7YHXTATCRRETQYFPL3ANCNFSM4JZBRRZA>
.
|
Most likely GHC 8.8 manages to figure out a top-level signature warning even in the presence of warnings. I wonder if we should explicitly omit suggesting signatures with Any in them, as its almost never what anyone wants. |
Reproduced with hls-1.5.0 and ghc-8.10.7 |
I second this. |
Reproduced with GHC 9.8.2 & HLS 2.8.0.0 |
Co-authored-by: soulomoon <[email protected]>
I wanted to play around with the new functionality to insert type signatures. The following:
surprises me, as when I add a type signature with a code action, I get:
which is mostly certainly not what I'd expect!
The text was updated successfully, but these errors were encountered: