Opened 11 months ago
Last modified 9 months ago
#14180 new bug
Strange/bad error message binding unboxed type variable
Reported by: | dfeuer | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | 8.2.3 |
Component: | Compiler (Type checker) | Version: | 8.3 |
Keywords: | TypeInType | Cc: | goldfire |
Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
Type of failure: | None/Unknown | Test Case: | |
Blocked By: | Blocking: | ||
Related Tickets: | Differential Rev(s): | ||
Wiki Page: |
Description
{-# language TypeInType, TypeFamilies, MagicHash #-} import GHC.Exts type family MatchInt (f :: Int) :: () where MatchInt ('I# x) = '()
produces
<interactive>:2:59: error: • Couldn't match a lifted type with an unlifted type When matching kinds k0 :: * Int# :: TYPE 'IntRep Expected kind ‘Int#’, but ‘x’ has kind ‘k0’ • In the first argument of ‘ 'I#’, namely ‘x’ In the first argument of ‘MatchInt’, namely ‘( 'I# x)’ In the type family declaration for ‘MatchInt’
If, however, I replace x
in the pattern with _
, the type checker is satisfied. If I give it a pattern signature,
MatchInt ('I# (x :: Int#)) = '()
I get a different (and equally unhelpful) error message,
• Expecting a lifted type, but ‘Int#’ is unlifted • In the kind ‘Int#’ In the first argument of ‘ 'I#’, namely ‘(x :: Int#)’ In the first argument of ‘MatchInt’, namely ‘( 'I# (x :: Int#))’
Change History (4)
comment:1 Changed 11 months ago by
Cc: | goldfire added |
---|
comment:2 follow-up: 3 Changed 11 months ago by
comment:3 Changed 11 months ago by
Replying to simonpj:
What do you expect to happen here? We just don't have unboxed ints at the type level. Doubtless the error message could be improved.
Well, a message to that effect would be much better than what we get now! But I don't have a sufficiently clear sense of exactly what is and is not allowed to write it myself. Something about variables bound in type families not being able to have kinds of kind TYPE r
unless r ~ PtrRepLifted
, perhaps?
comment:4 Changed 9 months ago by
Milestone: | 8.2.2 → 8.2.3 |
---|
It looks like this won't be fixed for 8.2.2.
What do you expect to happen here? We just don't have unboxed ints at the type level. Doubtless the error message could be improved.