   # Does this scope reference any variables that need to be declared in the
   # given function body?
   hasDeclarations: (body) ->
-    body is @expressions and @any (k, val) -> val in ['var', 'reuse']
+    body is @expressions and @any (v) -> v.type in ['var', 'reuse']
 
   # Does this scope reference any assignments that need to be declared at the
   # top of the given function body?
   hasAssignments: (body) ->
-    body is @expressions and @any (k, val) -> val.assigned
+    body is @expressions and @any (v) -> v.type.assigned
 
   # Return the list of variables first declared in this scope.
   declaredVariables: ->

    !!@parent?.check name

  # Generate a temporary variable name at the given index.
  temporary: (type, index) ->
    if type.length > 1
      '_' + type + if index > 1 then index else ''
    else
      '_' + (index + parseInt type, 36).toString(36).replace /\d/g, 'a'
  
  # Gets the type of a variable.
  type: (name) ->

    if @positions.hasOwnProperty name
      @variables[@positions[name]].type = type
    else
      @positions[name] = -1 + @variables.push {name, type}
    this

  # Create a new garbage level
  startLevel: ->
    @garbage.push []
    this

  # Return to the previous garbage level and erase referenced temporary
  # variables in current level from scope.
  endLevel: ->
    @setVar name, 'reuse' for name in @garbage.pop() when @type(name) is 'var'
    this

  # Look up a variable name in lexical scope, and declare it if it does not
  # already exist.
