forked from GitHub/gf-core
Don't evaluate builtins with free variables as arguments
This commit is contained in:
@@ -207,14 +207,19 @@ eval env (S t1 t2) vs = do v1 <- eval env t1 []
|
|||||||
eval env (Let (x,(_,t1)) t2) vs = do tnk <- newThunk env t1
|
eval env (Let (x,(_,t1)) t2) vs = do tnk <- newThunk env t1
|
||||||
eval ((x,tnk):env) t2 vs
|
eval ((x,tnk):env) t2 vs
|
||||||
eval env (Q q@(m,id)) vs
|
eval env (Q q@(m,id)) vs
|
||||||
| m == cPredef = do vs' <- mapM force vs
|
| m == cPredef = do vs' <- mapM force vs -- FIXME this does not allow for partial application!
|
||||||
res <- evalPredef id vs'
|
if any isVar vs'
|
||||||
case res of
|
then return (VApp q vs)
|
||||||
Const res -> return res
|
else do res <- evalPredef id vs'
|
||||||
RunTime -> return (VApp q vs)
|
case res of
|
||||||
NonExist -> return (VApp (cPredef,cNonExist) [])
|
Const res -> return res
|
||||||
|
RunTime -> return (VApp q vs)
|
||||||
|
NonExist -> return (VApp (cPredef,cNonExist) [])
|
||||||
| otherwise = do t <- getResDef q
|
| otherwise = do t <- getResDef q
|
||||||
eval env t vs
|
eval env t vs
|
||||||
|
where
|
||||||
|
isVar (VGen _ _) = True
|
||||||
|
isVar _ = False
|
||||||
eval env (QC q) vs = return (VApp q vs)
|
eval env (QC q) vs = return (VApp q vs)
|
||||||
eval env (C t1 t2) [] = do v1 <- eval env t1 []
|
eval env (C t1 t2) [] = do v1 <- eval env t1 []
|
||||||
v2 <- eval env t2 []
|
v2 <- eval env t2 []
|
||||||
|
|||||||
Reference in New Issue
Block a user