Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
877a9577
Commit
877a9577
authored
Jun 06, 2014
by
Dr. Heinrich Hördegen
Committed by
Joachim Breitner
Jun 09, 2014
Browse files
Better warning message for orphan instances (Ticket
#9178
)
Including a test case.
parent
4b4d81a6
Changes
6
Hide whitespace changes
Inline
Side-by-side
compiler/iface/MkIface.lhs
View file @
877a9577
...
...
@@ -879,6 +879,13 @@ instOrphWarn :: DynFlags -> PrintUnqualified -> ClsInst -> WarnMsg
instOrphWarn dflags unqual inst
= mkWarnMsg dflags (getSrcSpan inst) unqual $
hang (ptext (sLit "Orphan instance:")) 2 (pprInstanceHdr inst)
$$ text "To avoid this"
$$ nest 4 (vcat posibilities)
where
posibilities =
text "move the instance declaration to the module of the class or of the type, or" :
text "wrap the type with a newtype and declare the instance on the new type." :
[]
ruleOrphWarn :: DynFlags -> PrintUnqualified -> Module -> IfaceRule -> WarnMsg
ruleOrphWarn dflags unqual mod rule
...
...
testsuite/tests/warnings/should_compile/Makefile
0 → 100644
View file @
877a9577
TOP
=
../../..
include
$(TOP)/mk/boilerplate.mk
include
$(TOP)/mk/test.mk
testsuite/tests/warnings/should_compile/T9178.hs
0 → 100644
View file @
877a9577
module
T9178
where
import
T9178DataType
instance
Show
T9178_Type
where
show
_
=
undefined
\ No newline at end of file
testsuite/tests/warnings/should_compile/T9178.stderr
0 → 100644
View file @
877a9577
[1 of 2] Compiling T9178DataType ( T9178DataType.hs, T9178DataType.o )
[2 of 2] Compiling T9178 ( T9178.hs, T9178.o )
T9178.hs:8:10: Warning:
Orphan instance: instance Show T9178_Type
To avoid this
move the instance declaration to the module of the class or of the type, or
wrap the type with a newtype and declare the instance on the new type.
testsuite/tests/warnings/should_compile/T9178DataType.hs
0 → 100644
View file @
877a9577
module
T9178DataType
where
data
T9178_Type
testsuite/tests/warnings/should_compile/all.T
0 → 100644
View file @
877a9577
test
('
T9178
',
extra_clean
(['
T9178.o
',
'
T9178DataType.o
',
'
T9178.hi
',
'
T9178DataType.hi
']),
multimod_compile
,
['
T9178
',
'
-Wall
'])
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment