[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Nicolas Cannasse <warplayer@f...> |
| Subject: | Re: [Caml-list] 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.
I guess you can't have a "when" clause between two patterns, that sounds
logical since it applies to all patterns in the same "group".
Nicolas Cannasse