   # console.log (JSON.stringify type.type)
   ctx.extendSubstitution matchType inferredType.type, type.type#(substitute ctx.substitution, type).type
   # console.log "after", (printType inferredType.type)
+
   reduceConstraints ctx, inferredType.constraints
+  # We also need to match dependent variables
+  for c1 in inferredType.constraints
+    for c2 in type.constraints
+      constraintsEqual c1, c2
   #(substitute ctx.substitution, inferredType).constraints
   inferredType.constraints
 

  else
    to

constraintsFromCanonicalType = (ctx, canonicalType, type) ->
  inferredType = freshInstance ctx, canonicalType
  # console.log "canonicalType", canonicalType, type

          addedDep.scopeIndex ?= dep.scopeIndex
          addedDep.types.push dep.type
          if dep.defining
            depDeferredConstraints = lookupInMap allDeferredConstraints, dep.name
            # If depDeferredConstraints is null the dependency must be mutually dependant
            added.constraints = join added.constraints, depDeferredConstraints or []

