diff --git a/src/Defun.ml b/src/Defun.ml index 13484fb..1441922 100644 --- a/src/Defun.ml +++ b/src/Defun.ml @@ -65,7 +65,7 @@ let rec walk_term fs t = | S.LetVal (var, value, next) -> let fs, nNext = walk_term fs next in fs, T.LetVal(var, value, nNext) - | S.LetBlo (var, S.Lam(_, vars, body), next) -> + | S.LetBlo (var, S.Lam(self, vars, body), next) -> (* FIXME is handling of recursive functions correct? *) let fs, nNext = walk_term fs next in let fs, nBody = walk_term fs body in @@ -77,10 +77,13 @@ let rec walk_term fs t = vars (S.vvars (List.tl args)) in let thisTag = freshTag () in + let selfVars = (match self with + | S.Self self -> Atom.Set.singleton self + | S.NoSelf -> Atom.Set.empty) in let freeVars = Atom.Set.elements @@ Atom.Set.diff (S.fv_term body) - (Atom.Set.of_list vars) + (Atom.Set.union (Atom.Set.of_list vars) selfVars) in let thisFunc = T.Branch(thisTag, freeVars, nBody) in