Version française
Home     About     Download     Resources     Contact us    
Browse thread
Strange syntax error
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Richard Jones <rich@a...>
Subject: Strange syntax error
The following compiles fine:

  type t = { keyword : string; cost : float option; }
  
  let f =
    function
      | { keyword = keyword } when keyword.[0] = '-' -> keyword
      | { keyword = keyword; cost = None } -> keyword
      | _ -> failwith "whatever"

But this, which surely is equivalent, fails with a syntax error at the
second '|' character:

  type t = { keyword : string; cost : float option; }
  
  let f =
    function
      | { keyword = keyword } when keyword.[0] = '-' (* -> keyword *)
      | { keyword = keyword; cost = None } -> keyword
      | _ -> failwith "whatever"

OCaml 3.08.1.

Is this a parsing bug?

Rich.

--