   # if not translatedExpression # TODO: throw here?
   if ctx.isAtDefinition()
     to = ctx.definitionPattern()
-    ctx.setAssignTo (irDefinition expression.tea, translatedExpression, ctx.definitionId())
+    ctx.setAssignTo (irDefinition expression.tea, translatedExpression,
+      {name: ctx.definitionName(), scopeIndex: ctx.currentScopeIndex()})
     {precs, assigns} = patternCompile ctx, to, expression, polymorphic
     translationCache = ctx.resetAssignTo()
 

  freshId: ->
    @nameIndex++

  ## Deferring

  addToDeferredNames: (binding) ->

  sub = matchType inferredType.type, (substitute ctx.substitution, type).type
  (substitute sub, inferredType).constraints

irReference = (name, type, scopeIndex) ->
  {ir: irReferenceTranslate, name, type, scopeIndex}

irReferenceTranslate = (ctx, {name, type, scopeIndex}) ->
  if ctx.isMethod name, type
    translateIr ctx, (irMethod type, name)
  else
    finalType = addConstraintsFrom ctx, {type, name: name, scopeIndex: scopeIndex}, substitute ctx.substitution, type
    classParams = dictsForConstraint ctx, finalType.constraints
    if classParams.length > 0
      {arity} = ctx.savedDeclaration name, scopeIndex
      params = map validIdentifier, arity
      (irFunctionTranslate ctx,
        params: params
