From adbe9cd94d6e9fef2811c52863c70649b6145f14 Mon Sep 17 00:00:00 2001 From: krasimir Date: Sat, 8 Jan 2011 20:55:58 +0000 Subject: [PATCH] fix the computation of abstract expressions in the presence of implicit arguments --- src/runtime/haskell/PGF/Expr.hs | 8 ++++++-- testsuite/runtime/typecheck/implicit-arguments.gfs | 1 + testsuite/runtime/typecheck/implicit-arguments.gfs.gold | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/runtime/haskell/PGF/Expr.hs b/src/runtime/haskell/PGF/Expr.hs index 71e35be5e..db6e7cfd3 100644 --- a/src/runtime/haskell/PGF/Expr.hs +++ b/src/runtime/haskell/PGF/Expr.hs @@ -354,7 +354,9 @@ apply sig env (EFun f) vs = case Map.lookup f (fst sig) of Nothing -> VApp f vs Nothing -> error ("unknown function "++showCId f) apply sig env (EApp e1 e2) vs = apply sig env e1 (eval sig env e2 : vs) -apply sig env (EAbs _ x e) (v:vs) = apply sig (v:env) e vs +apply sig env (EAbs b x e) (v:vs) = case (b,v) of + (Implicit,VImplArg v) -> apply sig (v:env) e vs + (Explicit, v) -> apply sig (v:env) e vs apply sig env (EMeta i) vs = case snd sig i of Just e -> apply sig env e vs Nothing -> VMeta i env vs @@ -369,7 +371,9 @@ applyValue sig (VMeta i env vs0) vs = VMeta i env (vs0++vs) applyValue sig (VGen i vs0) vs = VGen i (vs0++vs) applyValue sig (VSusp i env vs0 k) vs = VSusp i env vs0 (\v -> applyValue sig (k v) vs) applyValue sig (VConst f vs0) vs = VConst f (vs0++vs) -applyValue sig (VClosure env (EAbs b x e)) (v:vs) = apply sig (v:env) e vs +applyValue sig (VClosure env (EAbs b x e)) (v:vs) = case (b,v) of + (Implicit,VImplArg v) -> apply sig (v:env) e vs + (Explicit, v) -> apply sig (v:env) e vs applyValue sig (VImplArg _) vs = error "implicit argument in function position" ----------------------------------------------------- diff --git a/testsuite/runtime/typecheck/implicit-arguments.gfs b/testsuite/runtime/typecheck/implicit-arguments.gfs index 5667a2647..49850aeef 100644 --- a/testsuite/runtime/typecheck/implicit-arguments.gfs +++ b/testsuite/runtime/typecheck/implicit-arguments.gfs @@ -8,3 +8,4 @@ ai <\x -> x : ({m},n : Node) -> Node> ai Node> ai Node> ai +pt -compute <\{n} -> n : ({n} : Node) -> Node> {n1} diff --git a/testsuite/runtime/typecheck/implicit-arguments.gfs.gold b/testsuite/runtime/typecheck/implicit-arguments.gfs.gold index e0a83f5b6..3292c2ea1 100644 --- a/testsuite/runtime/typecheck/implicit-arguments.gfs.gold +++ b/testsuite/runtime/typecheck/implicit-arguments.gfs.gold @@ -31,3 +31,5 @@ Expression: Type: Path n1 n1 Probability: 1.0 +n1 +