1
0
forked from GitHub/gf-core

normalize record types in overload resolution

This commit is contained in:
aarne
2006-11-18 20:54:10 +00:00
parent 9d3fd3c9cf
commit 8a55561cbf
2 changed files with 21 additions and 14 deletions

View File

@@ -17,21 +17,22 @@ incomplete resource Overload = open Grammar in {
mod = overload {
mod : A -> N -> CN
= \a,n -> AdjCN (PositA a) (UseN n) ;
= \a,n -> AdjCN (PositA a) (UseN n) ;
mod : AP -> N -> CN
= \a,n -> AdjCN a (UseN n) ;
= \a,n -> AdjCN a (UseN n) ;
mod : AP -> CN -> CN
= \a,n -> AdjCN a n ;
= \a,n -> AdjCN a n ;
mod : AdA -> A -> AP
= \m,a -> AdAP m (PositA a) ;
= \m,a -> AdAP m (PositA a) ;
mod : Quant -> N -> NP
= \q,n -> DetCN (DetSg (SgQuant q) NoOrd)
(UseN n) ;
= \q,n -> DetCN (DetSg (SgQuant q)
NoOrd) (UseN n) ;
mod : Quant -> CN -> NP
= \q,n -> DetCN (DetSg (SgQuant q) NoOrd) n ;
= \q,n -> DetCN (DetSg
(SgQuant q) NoOrd) n ;
mod : Predet -> N -> NP
= \q,n -> PredetNP q (DetCN (DetPl
(PlQuant IndefArt) NoNum NoOrd) (UseN n)) ;
= \q,n -> PredetNP q (DetCN (DetPl
(PlQuant IndefArt) NoNum NoOrd) (UseN n)) ;
mod : Num -> N -> NP
= \nu,n -> DetCN (DetPl (PlQuant
IndefArt) nu NoOrd) (UseN n)

View File

@@ -339,9 +339,13 @@ computeLType gr t = do
r' <- comp r
s' <- comp s
case (r',s') of
(RecType rs, RecType ss) -> checkErr $ plusRecType r' s'
(RecType rs, RecType ss) -> checkErr (plusRecType r' s') >>= comp
_ -> return $ ExtR r' s'
RecType fs -> do
let fs' = sortBy (\x y -> compare (fst x) (fst y)) fs
liftM RecType $ mapPairsM comp fs'
_ | isPredefConstant ty -> return ty
_ -> composOp comp ty
@@ -585,8 +589,8 @@ inferLType gr trm = case trm of
_ -> raise $ "no overload instance of" +++ prt f +++
"for" +++ unwords (map prtType tys) +++ "among" ++++
unlines [unwords (map prtType ty) | (ty,_) <- typs]
++++ "DEBUG" +++ unwords (map show tys) +++ ";" ++++
unlines (map (show . fst) typs) ----
++++ "DEBUG" +++ unwords (map show tys) +++ ";"
++++ unlines (map (show . fst) typs) ----
lookupOverloadInstance tys typs = lookup tys typs ---- use Map
@@ -822,8 +826,10 @@ checkEqLType env t u trm = do
checkWarn $ "WARNING: missing lock field" +++ unwords (map prt lo)
return t'
Bad s -> raise (s +++ "type of" +++ prt trm +++
": expected" ++++ prtType t' ++++
"inferred" ++++ prtType u' ++++ show u')
": expected:" +++ prtType t' ++++
"inferred:" +++ prtType u'
---- +++++ "DEBUG:" ++++ show t' ++++ show u'
)
where
-- t is a subtype of u