Skip to content

Testcase tcfail158 is broken

Test testsuite/tests/typecheck/should_fail/tcfail158.hs contains the following code:

{-# LANGUAGE ExplicitForAll #-}

-- This one actually crashed in 6.4.1
-- There's a kind error in the signature for bar, 
-- and we were recovering, and then crashing when we found
-- a scoped type variable not in scope

 data Val v sm = Val
 foo :: forall v sm. Val v sm
 foo = undefined
   where foo1 :: Val v sm
         foo1 = bar
 -- Correct type signature: bar :: forall v sm. Val v sm
 bar :: forall v. Val v
 bar = undefined foo

The expected test result in testsuite/tests/typecheck/should_fail/tcfail158.stderr is:

tcfail158.hs:1:1: error:
    The IO action ‘main’ is not defined in module ‘Main’

Issues:

  1. With a very high probability, the intention of this test was not to test on the missing main function. The intention was to test the error message for the type signature of function bar .
  2. The code for the definitions and functions start in column 2 and not in column 1.
  3. With an added main function GHC Versions 8.0, 8.2, 8.4 and 8.6 report the following error:
tcfail158.hs:17:18: error:
    • Expecting one more argument to ‘Val v’
      Expected a type, but ‘Val v’ has kind ‘* -> *’
    • In the type signature:
        bar :: forall v. Val v
  1. GHC HEAD version 8.7.20181112, however, reports:
tcfail158.hs:15:17: error:
    • Couldn't match expected type ‘Val v1 sm1’
                  with actual type ‘Val v0’
    • In the expression: bar
      In an equation for ‘foo1’: foo1 = bar
      In an equation for ‘foo’:
          foo
            = undefined
            where
                foo1 :: Val v sm
                foo1 = bar
    • Relevant bindings include
        foo1 :: Val v1 sm1 (bound at tcfail158.hs:15:10)

tcfail158.hs:17:18: error:
    • Expecting one more argument to ‘Val v’
      Expected a type, but ‘Val v’ has kind ‘* -> *’
    • In the type signature: bar :: forall v. Val v
               ^^^^^
tcfail158.hs:18:7: error:
    • Couldn't match kind ‘* -> *’ with ‘*’
      When matching types
        t0 :: *
        Val v :: * -> *
    • In the expression: undefined foo
      In an equation for ‘bar’: bar = undefined foo
    • Relevant bindings include
        bar :: Val v (bound at tcfail158.hs:18:1)

GHC HEAD reports errors in 3 different lines 15, 17 and 18. Fix the type signature in line 17 and GHC compiles successfully. The error messages produced by GHC HEAD are very confusing!

Trac metadata
Trac field Value
Version 8.7
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Test Suite
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information