forked from GitHub/gf-core
use the new more accurate location information for some error messages
This commit is contained in:
@@ -72,11 +72,10 @@ checkContext st = checkTyp st . cont2exp
|
|||||||
checkTyp :: SourceGrammar -> Type -> [Message]
|
checkTyp :: SourceGrammar -> Type -> [Message]
|
||||||
checkTyp gr typ = err (\x -> [text x]) ppConstrs $ justTypeCheck gr typ vType
|
checkTyp gr typ = err (\x -> [text x]) ppConstrs $ justTypeCheck gr typ vType
|
||||||
|
|
||||||
checkDef :: SourceGrammar -> Fun -> Type -> [L Equation] -> [Message]
|
checkDef :: SourceGrammar -> Fun -> Type -> Equation -> [Message]
|
||||||
checkDef gr (m,fun) typ eqs = err (\x -> [text x]) ppConstrs $ do
|
checkDef gr (m,fun) typ eq = err (\x -> [text x]) ppConstrs $ do
|
||||||
bcs <- mapM (\(L _ b) -> checkBranch (grammar2theory gr) (initTCEnv []) b (type2val typ)) eqs
|
(b,cs) <- checkBranch (grammar2theory gr) (initTCEnv []) eq (type2val typ)
|
||||||
let (bs,css) = unzip bcs
|
(constrs,_) <- unifyVal cs
|
||||||
(constrs,_) <- unifyVal (concat css)
|
|
||||||
return $ filter notJustMeta constrs
|
return $ filter notJustMeta constrs
|
||||||
|
|
||||||
checkConstrs :: SourceGrammar -> Cat -> [Ident] -> [String]
|
checkConstrs :: SourceGrammar -> Cat -> [Ident] -> [String]
|
||||||
|
|||||||
@@ -166,9 +166,9 @@ checkInfo ms (m,mo) c info = do
|
|||||||
mkCheck loc "type of function" $
|
mkCheck loc "type of function" $
|
||||||
checkTyp gr typ
|
checkTyp gr typ
|
||||||
case md of
|
case md of
|
||||||
Just eqs -> mkCheck loc "definition of function" $
|
Just eqs -> mapM_ (\(L loc eq) -> mkCheck loc "definition of function" $
|
||||||
checkDef gr (m,c) typ eqs
|
checkDef gr (m,c) typ eq) eqs
|
||||||
Nothing -> return info
|
Nothing -> return ()
|
||||||
return (AbsFun (Just (L loc typ)) ma md)
|
return (AbsFun (Just (L loc typ)) ma md)
|
||||||
|
|
||||||
CncFun linty@(Just (cat,cont,val)) (Just (L loc trm)) mpr -> chIn loc "linearization of" $ do
|
CncFun linty@(Just (cat,cont,val)) (Just (L loc trm)) mpr -> chIn loc "linearization of" $ do
|
||||||
@@ -187,17 +187,21 @@ checkInfo ms (m,mo) c info = do
|
|||||||
mpr <- checkPrintname gr mpr
|
mpr <- checkPrintname gr mpr
|
||||||
return (CncCat (Just (L loc typ)) mdef mpr)
|
return (CncCat (Just (L loc typ)) mdef mpr)
|
||||||
|
|
||||||
ResOper pty pde -> chIn (0,0) "operation" $ do
|
ResOper pty pde -> do
|
||||||
(pty', pde') <- case (pty,pde) of
|
(pty', pde') <- case (pty,pde) of
|
||||||
(Just (L loc1 ty), Just (L loc2 de)) -> do
|
(Just (L loct ty), Just (L locd de)) -> do
|
||||||
ty' <- checkLType gr [] ty typeType >>= computeLType gr [] . fst
|
ty' <- chIn loct "operation" $
|
||||||
(de',_) <- checkLType gr [] de ty'
|
checkLType gr [] ty typeType >>= computeLType gr [] . fst
|
||||||
return (Just (L loc1 ty'), Just (L loc2 de'))
|
(de',_) <- chIn locd "operation" $
|
||||||
(_ , Just (L loc de)) -> do
|
checkLType gr [] de ty'
|
||||||
(de',ty') <- inferLType gr [] de
|
return (Just (L loct ty'), Just (L locd de'))
|
||||||
return (Just (L loc ty'), Just (L loc de'))
|
(Nothing , Just (L locd de)) -> do
|
||||||
(_ , Nothing) -> do
|
(de',ty') <- chIn locd "operation" $
|
||||||
checkError (text "No definition given to the operation")
|
inferLType gr [] de
|
||||||
|
return (Just (L locd ty'), Just (L locd de'))
|
||||||
|
(Just (L loct ty), Nothing) -> do
|
||||||
|
chIn loct "operation" $
|
||||||
|
checkError (text "No definition given to the operation")
|
||||||
return (ResOper pty' pde')
|
return (ResOper pty' pde')
|
||||||
|
|
||||||
ResOverload os tysts -> chIn (0,0) "overloading" $ do
|
ResOverload os tysts -> chIn (0,0) "overloading" $ do
|
||||||
@@ -211,7 +215,7 @@ checkInfo ms (m,mo) c info = do
|
|||||||
sort [let (xs,t) = typeFormCnc x in t : map (\(b,x,t) -> t) xs | (_,x) <- tysts1]
|
sort [let (xs,t) = typeFormCnc x in t : map (\(b,x,t) -> t) xs | (_,x) <- tysts1]
|
||||||
return (ResOverload os [(y,x) | (x,y) <- tysts'])
|
return (ResOverload os [(y,x) | (x,y) <- tysts'])
|
||||||
|
|
||||||
ResParam (Just pcs) _ -> chIn (0,0) "parameter type" $ do
|
ResParam (Just pcs) _ -> do
|
||||||
ts <- checkErr $ liftM concat $ mapM mkPar pcs
|
ts <- checkErr $ liftM concat $ mapM mkPar pcs
|
||||||
return (ResParam (Just pcs) (Just ts))
|
return (ResParam (Just pcs) (Just ts))
|
||||||
|
|
||||||
@@ -220,9 +224,10 @@ checkInfo ms (m,mo) c info = do
|
|||||||
gr = MGrammar ((m,mo) : ms)
|
gr = MGrammar ((m,mo) : ms)
|
||||||
chIn loc cat = checkIn (text "Happened in" <+> text cat <+> ppIdent c <+> ppPosition m loc <> colon)
|
chIn loc cat = checkIn (text "Happened in" <+> text cat <+> ppIdent c <+> ppPosition m loc <> colon)
|
||||||
|
|
||||||
mkPar (L _ (f,co)) = do
|
mkPar (L loc (f,co)) =
|
||||||
vs <- liftM combinations $ mapM (\(_,_,ty) -> allParamValues gr ty) co
|
chIn loc "parameter type" $ do
|
||||||
return $ map (mkApp (QC m f)) vs
|
vs <- liftM combinations $ mapM (\(_,_,ty) -> allParamValues gr ty) co
|
||||||
|
return $ map (mkApp (QC m f)) vs
|
||||||
|
|
||||||
checkUniq xss = case xss of
|
checkUniq xss = case xss of
|
||||||
x:y:xs
|
x:y:xs
|
||||||
|
|||||||
Reference in New Issue
Block a user