       throw new Error "Macro #{name} already defined"
     else
       addToMap topScope.macros, name, macro
-  for name, {type, arity, docs, isClass, virtual} of values definitions when shouldImport name
-    addToMap topScope, name, {type, arity, docs, isClass, virtual}
+  for name, {type, arity, docs, isClass, virtual, final} of values definitions when shouldImport name
+    addToMap topScope, name, {type, arity, docs, isClass, virtual, final}
   topScope.typeNames = concatMaps topScope.typeNames, typeNames
   topScope.classes = concatMaps topScope.classes, classes
   ctx.scopeIndex += compiledModule.savedScopes.length


  # Properly bind types according to the pattern
  if pattern.tea
    # log "pattern", matched.tea, pattern.tea
    unify ctx, matched.tea.type, pattern.tea.type

  constraints = matched.tea.constraints

    # Name clash
    if (ctx.isFinallyDeclaredCurrentlyTyped name)
      malformed ctx, pattern, "#{name} is already declared"
      isMalformed = yes
    else
      if not ctx.isCurrentlyDeclared name
        # TODO: this is because functions might declare arity before being declared
        ctx.declare name, id: id
      if deps.length > 0
        # log "adding top level lhs to deferred #{name}", deps
        currentType = type#substitute ctx.substitution, type
        ctx.addToDeferredBindings
          name: scopedName name, ctx.currentScopeIndex()
          id: name
          scopeIndex: ctx.currentScopeIndex()
          type: currentType
          constraints: constraints
          polymorphic: polymorphic
          deps: deps#(map (({name}) -> name), deps)
        # for dep in deps
        #   ctx.addToDeferredBindings {name: dep.name, type: dep.type, reversed: name}
        if not ctx.isTyped name
          ctx.assignType name, (new TempType type)
      else
        # Ready for typing since there are no missing dependencies
        deferredConstraints = inferType ctx, name, type, constraints, polymorphic
        ctx.addToScopeConstraints deferredConstraints

  precs: precs ? []
  assigns: assigns ? []
  isMalformed: isMalformed

inferType = (ctx, name, type, constraints, polymorphic, scopeIndex) ->
  scopeIndex ?= ctx.currentScopeIndex()
