Opened 3 years ago

Closed 2 years ago

Last modified 2 years ago

#10224 closed bug (fixed)

Partial type signatures generate typed hole warnings

Reported by: quchen Owned by:
Priority: normal Milestone: 7.10.2
Component: Compiler Version: 7.10.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

GHCi generates typed hole warnings in type signatures even when PartialTypeSignatures is enabled:

> :set -XPartialTypeSignatures 

> :t (==) :: Char -> _
<interactive>:1:17: Warning:
    Found hole ‘_’ with type: Char -> Bool
    In an expression type signature: Char -> _
    In the expression: (==) :: Char -> _
(==) :: Char -> _ :: Char -> Char -> Bool

> :set -XNoPartialTypeSignatures

> :t (==) :: Char -> _
<interactive>:1:17:
    Found hole ‘_’ with type: Char -> Bool
    To use the inferred type, enable PartialTypeSignatures
    In an expression type signature: Char -> _
    In the expression: (==) :: Char -> _

Similarly, GHC 7.10.1, when given the following source,

{-# LANGUAGE PartialTypeSignatures #-}

f = (==) :: Char -> _

main = return ()

mentions that it "found a hole".

Change History (7)

comment:1 Changed 3 years ago by mpickering

I think this is the expected behaviour. From the user guide:

By default, the type-checker will report an error message for each hole in a partial type signature, informing the programmer of the inferred type. When the -XPartialTypeSignatures flag is enabled, the type-checker will accept the inferred type for each hole, generating warnings instead of errors. Additionally, these warnings can be silenced with the -fno-warn-partial-type-signatures flag.

comment:2 Changed 3 years ago by simonpj

Resolution: invalid
Status: newclosed

I think mpickering is right. Seem ok? I'll close as invalid, but reopen if you think this is wrong.

Simon

comment:3 Changed 2 years ago by goldfire

Resolution: invalid
Status: closednew

I find the warning message quite misleading. Here is my (uninteresting) case:

foo :: _ -> Bool
foo True = False
foo False = True

I get this warning (with -XPartialTypeSignatures)

Scratch.hs:18:8: warning:
    Found hole: _ :: Bool
    In the type signature for ‘foo’: _ -> Bool

I think of "hole" as something in an expression instead of a type. In a type, I thought it was called a "wildcard". In any case, _ :: Bool is wrong. My _ certainly does not have type Bool. It has value Bool. Here is my suggested output:

Scratch.hs:18:8: warning:
    Found type wildcard: `_' standing in for `Bool'
    In the type signature for ‘foo’: _ -> Bool

I'm reopening on the basis that, even if my hole vs. wildcard distinction is silly nitpicking, saying _ :: Bool is wrong and should be fixed.

comment:4 Changed 2 years ago by Simon Peyton Jones <simonpj@…>

In 9e86bf1b346934e04ccc17ec50ea7e7d906f25e2/ghc:

Better type wildcard errors

Adopts sugggestion in Trac #10224, comment:3

comment:5 Changed 2 years ago by simonpj

Resolution: fixed
Status: newclosed

Good idea

comment:6 Changed 2 years ago by Simon Peyton Jones <simonpj@…>

In d7335f74744a78bb468326b13fdd8b0c471eb71f/ghc:

Test Trac #10463

was fixed along with Trac #10224

comment:7 Changed 2 years ago by Thomas Miedema <thomasmiedema@…>

In f607393b7ffa8a06417e3f1263d2610d6bfe8279/ghc:

Testsuite: accept new stderr for T9497{a,b,c}-run (#10224)
Note: See TracTickets for help on using tickets.