Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,264
    • Issues 5,264
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 568
    • Merge requests 568
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #16894
Closed
Open
Issue created Jul 02, 2019 by Joey Hess@joeyhess

TypeError hides a second error message

Summary

Using TypeError seems to hide other type error messages due to eg, bad arguments passed to a function.

Steps to reproduce

Load into ghci:

{-# LANGUAGE DataKinds, UndecidableInstances, TypeFamilies #-}
import GHC.TypeLits

type family Check x :: Bool where
        Check 'True = 'True
        Check x = 'False

foo :: Check 'False ~ 'True => Int -> String
foo n = "never reached"

type family Check2 x :: Bool where
        Check2 'True = 'True
        Check2 x = TypeError ('Text "no")

foo2 :: Check2 'False ~ 'True => Int -> String
foo2 n = "never reached"
ghci> foo "bar"

<interactive>:69:1: error:
    • Couldn't match type ‘'False’ with ‘'True’
        arising from a use of ‘foo’
    • In the expression: foo "bar"
      In an equation for ‘it’: it = foo "bar"

<interactive>:69:5: error:
    • Couldn't match expected type ‘Int’ with actual type ‘[Char]’
    • In the first argument of ‘foo’, namely ‘"bar"’
      In the expression: foo "bar"
      In an equation for ‘it’: it = foo "bar"
ghci> foo2 "bar"

<interactive>:70:1: error:
    • no
    • In the expression: foo2 "bar"
      In an equation for ‘it’: it = foo2 "bar"

Expected behavior

I expected to see the same error about Int vs [Char] for foo2 as is shown for foo, as well as the custom TypeError. However, the use of TypeError somehow prevents the Int vs [Char] error from being displayed.

This is preventing me from using TypeError in situations where there might be another, more basic type error in the same code.

This may be related to #14771

Environment

  • GHC version used: 8.4.4, 8.6.5
Edited Jul 02, 2019 by Joey Hess
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking