 
         visitFunction: (n) ->
                 current_env = @envs.top if @envs.depth > 0
-                new_env = { id: @env_id, decls: (if n.ejs_decls? then n.ejs_decls else new Set), closed: new Set, parent: current_env }
+                new_env = { exp: n, id: @env_id, decls: (if n.ejs_decls? then n.ejs_decls else new Set), closed: new Set, parent: current_env }
                 @env_id += 1
                 n.ejs_env = new_env
                 @envs.push new_env

                @envs.pop()
                n

        visitVariableDeclarator: (n) ->
                # don't visit the id, as that will cause us to mark it ejs_substitute = true, and we'll end up with things like:
                #   var %env_1.x = blah

                                else
                                        env.nested_requires_env = true
                                        env = env.parent
                else
                        console.log "identifier #{n.name} is not closed over"
                
                n.ejs_substitute = true
                n
