Been trying to compile some code for Standard ML, but it keeps getting hickups with the use of cons, anyone know what is causing this?

This is the errors that the compiler spits out.
Code:
test.sml:4.7-7.55 Error: non-constructor applied to argument in pattern: cons
test.sml:7.45-7.53 Error: unbound variable or constructor: V2_87300
test.sml:7.17-7.21 Error: unbound variable or constructor: cons
test.sml:7.23-7.31 Error: unbound variable or constructor: V2_872ff
And the code.
Code:
fun f (V2_4) =
  let
    fun g2_86a47 (( V2_87117, V2_86a48 )) =
      case V2_86a48 of
        nil => V2_87117
      | cons( V2_872ff, V2_87300 ) =>
      g2_86a47( cons( V2_872ff, V2_87117 ), V2_87300 )
  in
    g2_86a47( nil, V2_4 )
  end