[project @ 2004-09-07 12:30:27 by simonmar]
authorsimonmar <unknown>
Tue, 7 Sep 2004 12:30:28 +0000 (12:30 +0000)
committersimonmar <unknown>
Tue, 7 Sep 2004 12:30:28 +0000 (12:30 +0000)
Fix up the SrcSpan on the rhs of a function binding.

ghc/compiler/parser/Parser.y.pp
ghc/compiler/parser/RdrHsSyn.lhs

index 2ba5ae0..83b299a 100644 (file)
@@ -941,7 +941,7 @@ deriving :: { Located (Maybe [LHsType RdrName]) }
 
 decl   :: { Located (OrdList (LHsDecl RdrName)) }
        : sigdecl                       { $1 }
-       | infixexp opt_sig rhs          {% do { r <- checkValDef $1 $2 (unLoc $3);
+       | infixexp opt_sig rhs          {% do { r <- checkValDef $1 $2 $3;
                                                return (LL $ unitOL (LL $ ValD r)) } }
 
 rhs    :: { Located (GRHSs RdrName) }
index 781b085..6fb6e86 100644 (file)
@@ -762,17 +762,16 @@ patFail loc = parseError loc "Parse error in pattern"
 checkValDef 
        :: LHsExpr RdrName
        -> Maybe (LHsType RdrName)
-       -> GRHSs RdrName
+       -> Located (GRHSs RdrName)
        -> P (HsBind RdrName)
 
-checkValDef lhs opt_sig grhss
+checkValDef lhs opt_sig (L rhs_span grhss)
   | Just (f,inf,es)  <- isFunLhs lhs []
   = if isQual (unLoc f)
        then parseError (getLoc f) ("Qualified name in function definition: "  ++ 
                                        showRdrName (unLoc f))
        else do ps <- checkPatterns es
-               return (FunBind f inf [L (getLoc f) (Match ps opt_sig grhss)])
-                       -- TODO: span is wrong
+               return (FunBind f inf [L rhs_span (Match ps opt_sig grhss)])
   | otherwise = do
        lhs <- checkPattern lhs
        return (PatBind lhs grhss)