     cloneMap @_scope()
 
   assignType: (name, type) ->
-    if declaration = @_declarationInCurrentScope name
+    @assignTypeTo name, (@_declarationInCurrentScope name), type
+
+  assignTypeLate: (name, scopeIndex, type) ->
+    if scopeIndex isnt @currentScopeIndex()
+      @assignTypeTo name, (@savedDeclaration name, scopeIndex), type
+    else
+      @assignType name, type
+
+  assignTypeTo: (name, declaration, type) ->
+    if declaration
       if declaration.type and declaration.type not instanceof TempType
         throw new Error "assignType: #{name} already has a type"
       declaration.type = type

    declaration.final = no
    @_declare name, declaration

  declareAsFinal: (name) ->
    (@_declarationInCurrentScope name).final = yes

  _declare: (name, declaration) ->
    declaration.id ?= @freshId()


  addToDeferred: (binding) ->
    @_scope().deferredBindings.push binding

  addToParentDeferred: (binding) ->
    @_outerScope().deferredBindings.push binding

  addToDefinedNames: (binding) ->
    @_currentDefinition()?.definedNames?.push binding
