diff options
author | Jeremie Dimino <jdimino@janestreet.com> | 2015-11-05 10:26:15 +0000 |
---|---|---|
committer | Jeremie Dimino <jdimino@janestreet.com> | 2015-11-05 10:41:13 +0000 |
commit | 6676784f6320aa9e415261fca1154c5447fa7a13 (patch) | |
tree | 8e7648eddbe6195d6b6a1819e3eca0b2132e4265 | |
parent | 26657d5736b1b663072ea9ca17957875b909286d (diff) | |
download | ocaml-6676784f6320aa9e415261fca1154c5447fa7a13.tar.gz |
PR#6806: Allow type annotations before the "->" in "fun <args> -> <expr>"
Patch by Valentin Gatien-Baron
-rw-r--r-- | Changes | 2 | ||||
-rw-r--r-- | parsing/parser.mly | 3 | ||||
-rw-r--r-- | testsuite/tests/typing-warnings/coercions.ml | 2 |
3 files changed, 5 insertions, 2 deletions
@@ -51,6 +51,8 @@ Language features: (Pierre Chambart, Mark Shinwell) - PR#6806: Syntax shortcut for putting a type annotation on a record field (Valentin Gatien-Baron, review by Jérémie Dimino) +- PR#6806: Allow type annotations before the "->" in "fun <args> -> <expr>" + (Valentin Gatien-Baron, review by Jérémie Dimino) Compilers: - PR#4800: better compilation of tuple assignment (Gabriel Scherer and diff --git a/parsing/parser.mly b/parsing/parser.mly index 10296e7cdb..6210cc5d3d 100644 --- a/parsing/parser.mly +++ b/parsing/parser.mly @@ -1557,7 +1557,8 @@ match_case: { Exp.case $1 (Exp.unreachable ~loc:(rhs_loc 3) ())} ; fun_def: - MINUSGREATER seq_expr { $2 } + MINUSGREATER seq_expr { $2 } + | COLON simple_core_type MINUSGREATER seq_expr { mkexp (Pexp_constraint ($4, $2)) } /* Cf #5939: we used to accept (fun p when e0 -> e) */ | labeled_simple_pattern fun_def { diff --git a/testsuite/tests/typing-warnings/coercions.ml b/testsuite/tests/typing-warnings/coercions.ml index 1ca390b28e..d5126e916c 100644 --- a/testsuite/tests/typing-warnings/coercions.ml +++ b/testsuite/tests/typing-warnings/coercions.ml @@ -2,4 +2,4 @@ fun b -> if b then format_of_string "x" else "y";; fun b -> if b then "x" else format_of_string "y";; -fun b -> (if b then "x" else "y" : (_,_,_) format);; +fun b : (_,_,_) format -> if b then "x" else "y";; |