Bad error messages for SPECIALIZE pragmas
When playing with SPECIALIZE pragmas, I've encountered one large problem with the error messages, and two minor ones.
- Given a function with a
Num
constraint, applyingSPECIALIZE
at a non-function type triggers defaulting incorrectly; the code
f1 :: Num a => a -> a
f1 x = x + x
{-# SPECIALIZE f1 :: Bool #-}
produces the error
…/Test1.hs:5:1: error:
• Couldn't match expected type ‘Integer -> Integer’
with actual type ‘Bool’
• In the SPECIALISE pragma {-# SPECIALIZE f1 :: Bool #-}
(This is in the attached file Test1.hs
.)
- Given a function, applying
SPECIALIZE
at a well-formed type without the looked-for instance produces an error with some extra text (the first line ends with "a SPECIALISE pragma for ‘f2’", even though this is repeated on the next line); the code
f2 :: Num a => a -> a
f2 x = x + x
{-# SPECIALIZE f2 :: Bool -> Bool #-}
produces the error
…/Test2.hs:5:1: error:
• No instance for (Num Bool) a SPECIALISE pragma for ‘f2’
• In the SPECIALISE pragma {-# SPECIALIZE f2 :: Bool -> Bool #-}
(This is in the attached file Test2.hs
.)
- This is minor, but: both of these error messages talk about a
SPECIALISE
pragma when I wrote aSPECIALIZE
pragma. Even more so, case is not preserved in the quoted pragma; if I provide a
{-# specialize … #-}
pragma, the error message ends with
• In the SPECIALISE pragma {-# SPECIALIZE … #-}`.
even though that isn't what I wrote.
Trac metadata
Trac field | Value |
---|---|
Version | 8.0.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | antal.b.sz@gmail.com |
Operating system | |
Architecture |