Skip to content

Latest commit

 

History

History
39 lines (28 loc) · 611 Bytes

5014.md

File metadata and controls

39 lines (28 loc) · 611 Bytes

5014

A constructor had an argument in a pattern match, but it was defined to have no argument in the datatype.

datatype d = A | B of int

fun f x =
  case x of
    A y => y + 1
(** ^^^ unexpected argument for constructor pattern *)
  | B z => z - 1

To fix

Try one of the following:

  • Remove the argument from the pattern:

    datatype d = A | B of int
    
    fun f x =
      case x of
        A => 1
      | B z => z - 1
  • Define the constructor to have an argument:

    datatype d = A of int | B of int
    
    fun f x =
      case x of
        A y => y + 1
      | B z => z - 1