   # 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()
 

  """
  '(h 3)', 2


  # TODO: support matching with the same name
  #       to implement this we need the iife to take as arguments all variables

      translateIr ctx, op
  (jsCall op, (join classParams, (translateIr ctx, args)))

addConstraintsFrom = (ctx, {name, type, scopeIndex}, to) ->
  if scopeIndex? and (typed = ctx.savedDeclaration name, scopeIndex) and
      (_empty to.constraints) and
      (_notEmpty typed.type.type.constraints)
    addConstraints to, constraintsFromCanonicalType ctx, typed.type, type
  else
    to

