[ ghc-Bugs-1234239 ] Bad location for violation of functional
dependency
SourceForge.net
noreply at sourceforge.net
Thu Jul 7 11:44:13 EDT 2005
Bugs item #1234239, was opened at 2005-07-07 15:44
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=1234239&group_id=8032
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Compiler (Type checker)
Group: 6.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Mike Gunter (magunter)
Assigned to: Nobody/Anonymous (nobody)
Summary: Bad location for violation of functional dependency
Initial Comment:
The code below produces an error message which gives no
clue
that the actual source of the error is on the line
marked L3
(pointing instead to L1 and L2):
.../BadWarningLoc.hs:1:0:
Couldn't match `S Z' against `Z'
Expected type: S Z
Inferred type: Z
When using functional dependencies to combine
MinMax a Z Z a,
arising from the instance declaration at
.../BadWarningLoc.hs:10:0
MinMax (S Z) Z _c d,
arising from use of `t' at .../BadWarningLoc.hs:21:8-10
With the type signature, marked L4, uncommented the error
message does indeed point to the culprit, L3.
(With L3 commented-out, the code compiles.)
thanks,
mike
{-# OPTIONS_GHC -fglasgow-exts
-fallow-undecidable-instances #-}
data Z = Z
data S a = S a
n0 = Z
n1 = S n0
class MinMax a b c d | a b -> c d, a c d -> b, b c d -> a
instance MinMax Z Z Z Z
instance MinMax a Z Z a -- L1: wrongly flagged as
error src.
instance MinMax Z b Z b
instance MinMax a b c d => MinMax (S a) (S b) (S c) (S d)
class Extend a b where extend :: a -> b -> b
instance Extend Z b where Z `extend` b = b
instance MinMax a b _c b => Extend a b where _a
`extend` b = b
t :: MinMax a b _c d => a -> b -> d
t _ _ = (undefined :: d)
t1 = n1 `t` n0 -- L2
t2 = n1 `extend` n0 -- L3: uncommenting just this line
produces
-- an error message pointing at L1 and L2
-- with no mention of the real culprit, L3.
--t1 :: S Z -- L4: uncommenting this and L3 produces an
-- error message rightly pointing at L2 and L3.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=1234239&group_id=8032
More information about the Glasgow-haskell-bugs
mailing list