     }
   else
     module = lookupCompiledModule moduleName
-    {modules, ctx} = contextWithDependencies moduleName
+    {modules, ctx} = contextWithDependencies moduleDependencies moduleName
     [expression] = _terms ast
     compilationFn = (topLevelExpressionInModule importsFor moduleDependencies moduleName)
     {js} = compileCtxAstToJs compilationFn, ctx, expression


findMatchingDefinitionsOnType = (type, definitionLists) ->
  ctx = new Context
  [typed, untyped] = unzip (for definitions, i in definitionLists
    isValid = (name, def) ->
      def.type? and not def.type.TempType

    setToArray (lookupCompiledModule name).declared.definitions
  mapKeys lookupDefinitions, moduleSet

contextWithDependencies = (modules) ->
  ctx: injectedContext modules
  modules: setToArray modules

moduleDependencies = (moduleName) ->
  concatSets (collectRequiresFor moduleName), (newSetWith moduleName)

reverseModuleDependencies = (moduleName) ->
  concatSets (newSetWith moduleName), (collectRequiresFor moduleName)

# Primitive type checking for now
checkTypes = (ctx) ->
