 
 injectContext = (ctx, compiledModule) ->
   {definitions, typeNames, classes, macros} = compiledModule
+  topScope = ctx._scope()
   for name, macro of values macros
-    if ctx._macros[name]
+    if ctx.isMacroDeclared name
       throw new Error "Macro #{name} already defined"
     else
-      ctx._macros[name] = macro
-  topScope = ctx._scope()
+      addToMap topScope.macros, name, macro
   for name, definition of values definitions
     addToMap topScope, name, definition
   topScope.typeNames = concatMaps topScope.typeNames, typeNames

    @classParams = newMap()
    @types = []
    @isMalformed = no

  macros: ->
    @_macros

  addMacro: (name, macro) ->
    @_macros[name.symbol] = macro
    name.id = macro.id = @freshId()

  markMalformed: ->
    @isMalformed = yes


      # Arity - before deferring instead? put to assignCompile, because this makes the naming of functions special
      if name = ctx.isAtSimpleDefinition()
        # Explicit typing
        if type
          explicitType = declareExplicitlyTyped ctx, typeConstrainedCompile ctx, type
          ctx.assignArity name, paramNames
        else
          ctx.declare name,
            arity: paramNames
            id: ctx.definitionId()
            type: ctx.preDeclaredType name # if any

      newParamType = (param) ->
        markOrigin (ctx.freshTypeVariable star), param
