Opened 4 years ago

Closed 4 years ago

#10516 closed bug (fixed)

PolyKinds results in incorrect reporting of type synonym parameter count

Reported by: benjamin.hodgson Owned by:
Priority: high Milestone: 7.10.3
Component: Compiler Version: 7.10.1
Keywords: Cc:
Operating System: MacOS X Architecture: x86_64 (amd64)
Type of failure: None/Unknown Test Case: polykinds/T10516
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by benjamin.hodgson)

The following program is invalid because the declaration of f doesn't fully apply App to all of its arguments.

{-# LANGUAGE PolyKinds #-}

type App f a = f a

newtype X f a = X (f a)

f :: f a -> X (App f) a
f = X

However, with the PolyKinds extension, the error reporting is quite weird:

Type synonym ‘App’ should have 4 arguments, but has been given 3
In the type signature for ‘f’: f :: f a -> X (App f) a

App has two arguments, and I gave it one! I'm guessing that PolyKinds makes GHC supply some implicit parameters during expansion of type synonyms, and that's what gets reported in the error message. The behaviour is correct without PolyKinds.

I've tested this on GHC 7.8.3 (the Haskell Platform version) on my 64-bit OSX Yosemite system.

Change History (6)

comment:1 Changed 4 years ago by benjamin.hodgson

Description: modified (diff)

comment:2 Changed 4 years ago by goldfire

Confirmed reproducible in HEAD and 7.10.1.

Thanks for reporting!

comment:3 Changed 4 years ago by goldfire


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

In 5879d5aab929e9959d48e03dad456b824160b3bf/ghc:

Report arity errors correctly despite kinds

Trac #10516 pointed out that when reporting arity errors
(like "T needs 2 arguments but has been given 1"), we should
not count kind arguments, since they are implicit.  If we
include kind args in the count, we get very confusing error
messages indeed.

I did a little bit of refactoring which make some
error messages wobble around.  But the payload of
this fix is in TcValidity.tyConArityErr

comment:5 Changed 4 years ago by simonpj

Milestone: 7.10.3
Priority: normalhigh
Status: newmerge
Test Case: polykinds/T10516

I believe I have fixed this. Could merge to the branch if convenient.


comment:6 Changed 4 years ago by bgamari

Resolution: fixed
Status: mergeclosed

It sadly doesn't look like this will be terribly convenient. Punting.

Note: See TracTickets for help on using tickets.