From ac5cbb7913a3e260a8d48a1a41d6350e5cf53664 Mon Sep 17 00:00:00 2001 From: Alain Frisch Date: Mon, 16 Dec 2013 17:34:23 +0000 Subject: #5808: allow simple patterns, not only identifiers, in 'let p : t = ...'. git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14362 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02 --- Changes | 1 + parsing/parser.mly | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Changes b/Changes index e515cb2c90..927e483ac2 100644 --- a/Changes +++ b/Changes @@ -63,6 +63,7 @@ Features wishes: - PR#6071: Add a -noinit option to the toplevel (patch by David Sheets) - PR#6166: document -ocamldoc option of ocamlbuild - PR#6246: allow wilcard _ as for-loop index +- PR#5808: allow simple patterns, not only identifiers, in "let p : t = ..." OCaml 4.01.1: ------------- diff --git a/parsing/parser.mly b/parsing/parser.mly index 3bb6620876..f08afc21dc 100644 --- a/parsing/parser.mly +++ b/parsing/parser.mly @@ -1248,6 +1248,8 @@ let_binding_: (ghpat(Ppat_constraint(mkpatvar $1 1, poly)), exp) } | pattern EQUAL seq_expr { ($1, $3) } + | simple_pattern_not_ident COLON core_type EQUAL seq_expr + { (ghpat(Ppat_constraint($1, $3)), $5) } ; fun_binding: strict_binding @@ -1356,6 +1358,9 @@ pattern: simple_pattern: val_ident %prec below_EQUAL { mkpat(Ppat_var (mkrhs $1 1)) } + | simple_pattern_not_ident { $1 } +; +simple_pattern_not_ident: | UNDERSCORE { mkpat(Ppat_any) } | signed_constant -- cgit v1.2.1