     s2 = mostGeneralUnifier (substitute s1, t1.arg), (substitute s1, t2.arg)
     joinSubs s1, s2
   else if t1.Types and t2.Types
-    if _notEmpty t1.types
+    if t1.types.length isnt t2.types.length
+      unifyFail t1, t2
+    else if _notEmpty t1.types
       s1 = mostGeneralUnifier t1.types[0], t2.types[0]
       s2 = mostGeneralUnifier (new Types t1.types[1...]), (new Types t2.types[1...])
       joinSubs s1, s2


toHtml = (highlighted) ->
  crawl highlighted, (word, symbol, parent) ->
    (word.ws or '') + colorize(theme[labelOf word], symbol)

labelOf = (word) ->
  word.malformed and 'malformed' or word.label or 'normal'

collapse = (nodes) ->
  collapsed = ""

      # newMapWith "could not unify", [(safePrintType t1), (safePrintType t2)]
      unifyFail t1, t2
  else if t1.Types and t2.Types
    if t1.types.length isnt t2.types.length
      unifyFail t1, t2
    else if _notEmpty t1.types
      s1 = matchType t1.types[0], t2.types[0]
      s2 = matchType (new Types t1.types[1...]), (new Types t2.types[1...])
      s3 = mergeSubs s1, s2
