stage restriction mentioned when an identifier is out of scope
{-# LANGUAGE TemplateHaskell #-}
import Data.Monoid
const (return []) $ mempty { getFrst = Just () }
typeErrBug.hs:5:21: error:
• GHC stage restriction:
‘getFrst’ is used in a top-level splice, quasi-quote, or annotation,
and must be imported, not defined locally
• In the second argument of ‘($)’, namely
‘mempty {getFrst = Just ()}’
In the expression: const (return []) $ mempty {getFrst = Just ()}
typeErrBug.hs:5:30: error:
Not in scope: ‘getFrst’
Perhaps you meant one of these:
‘getFirst’ (imported from Data.Monoid),
‘getLast’ (imported from Data.Monoid)
The stage restriction error shouldn't be mentioned: getFrst
isn't defined at all while the "not defined locally" phrase says it's defined (in the wrong spot).
Trac metadata
Trac field | Value |
---|---|
Version | 8.0.1-rc2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |