           addDependency child.set, name for name in parent.names unless child is parent
           addDependency deps, parent
         else if !node.label and !lookupIdentifier token, node
-          child.missing.push node.token
+          addDependency child.missing, node.token
   [graph, lookupByName]
 
 lookupTableForGraph = (graph) ->

  [readyWheres, hoistableWheres] = wheresWithHoisting wheres
  addToScopeAllNames readyWheres
  wheresDef = (graphToWheres readyWheres).map(compileDef).join '\n'
  bodyDef = compileImpl body, graphToWheres hoistableWheres
  [wheresDef, bodyDef]

unpairs = (pairs) ->

compileName = (node) ->
  validIdentifier node.token

hoistWheres = (hoistable, assigns) ->
  defined = addAllTo dependencySet(), (n for [n, _] in assigns)
  hoistedNames = dependencySet()
  hoisted = []
  notHoisted = []
  for where in hoistable
    {missing, names, def, set} = where
    stillMissingNames = addAllTo dependencySet(), (name for name of missing when not defined[name])
    if stillMissingNames.numDependencies == 0 and set.numDependencies == 0
      hoisted.push def
      addAllTo hoistedNames, names
    else
      notHoisted.push
        def: def
        names: names
        missing: stillMissingNames
        set: removeAll (cloneDependencySet set), setToArray hoistedNames

  [hoisted, notHoisted]

addAllTo = (set, array) ->
  for v in array
    addDependency set, v
  set

removeAll = (set, array) ->
  for v in array
    removeDependency set, v
  set

setToArray = (set) ->
  for n of set.dependencies
    n


toJsString = (token) ->
  "'#{token}'"
