   'match': (hoistableWheres, onwhat, cases...) ->
     varNames = []
     if not onwhat
-      throw new Error 'match `onwhat` missing'
+      throw new Error 'match `onwhat:` missing'
     exp = compileImpl onwhat
+    if cases.length % 2 != 0
+      throw new Error 'match missing result for last pattern'
     compiledCases = (for [pattern, result], i in pairs cases
       control = if i is 0 then 'if' else ' else if'
       {precs, assigns} = patternMatch pattern, exp, mainCache

  ]

graphToWheres = (graph) ->
  graph.map ({def}) -> def

# Returns two new graphs, one which needs hoisting and one which doesnt
findHoistableWheres = ([graph, lookupTable]) ->

      else
        varNames.push vars...
      {conds, preassigns} = constructCond precs
      [hoistedWheres, furtherHoistable] = hoistWheres hoistableWheres, assigns
      #log "assigns", printAst assigns
      """#{control} (#{conds}) {
           #{preassigns.concat(assigns).map(compileAssign).join '\n'}
           #{hoistedWheres.map(compileDef).join '\n'}
           return #{compileImpl result, furtherHoistable};
        }"""
      )
    mainCache ?= []
