summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabriel Scherer <gabriel.scherer@gmail.com>2014-11-16 17:52:26 +0000
committerGabriel Scherer <gabriel.scherer@gmail.com>2014-11-16 17:52:26 +0000
commiteece1bbe45e4cd18b2a2487b00ee90632aba0e37 (patch)
tree2e87e54e0ad2f61744588fe814de7cce98991952
parent8591c2532ee6040bf961cf1a5b426d513e351dbe (diff)
Add punning for object copying expressions.
From: Jeremy Yallop <yallop@gmail.com> git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15580 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--Changes8
-rw-r--r--parsing/parser.mly22
2 files changed, 19 insertions, 11 deletions
diff --git a/Changes b/Changes
index 3b5035b8e..cea1d08c3 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,12 @@
OCaml 4.03.0:
-------------
+Language features:
+- PR#6374: allow "_ t" as a short-hand for "(_, _, ..) t" for n-ary type
+ constructors (Alain Frisch)
+- allow field punning in object copying expressions: {< x; >} for {< x = x; >}
+ (Jeremy Yallop)
+
Compilers:
- PR#6501: harden the native-code generator against certain uses of "%identity"
(Xavier Leroy, report by Antoine Miné).
@@ -16,8 +22,6 @@ Standard library:
- PR#6585: fix memory leak in win32unix/createprocess.c
Type system:
-- PR#6374: allow "_ t" as a short-hand for "(_, _, ..) t" for n-ary type
- constructors (Alain Frisch)
* PR#6465: allow incremental weakening of module aliases (Jacques Garrigue).
This is done by adding equations to submodules when expanding aliases.
In theory this may be incompatible is some corner cases defining a module
diff --git a/parsing/parser.mly b/parsing/parser.mly
index 7366fd747..3210c4a0e 100644
--- a/parsing/parser.mly
+++ b/parsing/parser.mly
@@ -1264,15 +1264,15 @@ simple_expr:
{ mkexp(Pexp_apply(mkoperator "!" 1, ["",$2])) }
| NEW ext_attributes class_longident
{ mkexp_attrs (Pexp_new(mkrhs $3 3)) $2 }
- | LBRACELESS field_expr_list opt_semi GREATERRBRACE
- { mkexp (Pexp_override(List.rev $2)) }
- | LBRACELESS field_expr_list opt_semi error
+ | LBRACELESS field_expr_list GREATERRBRACE
+ { mkexp (Pexp_override $2) }
+ | LBRACELESS field_expr_list error
{ unclosed "{<" 1 ">}" 4 }
| LBRACELESS GREATERRBRACE
{ mkexp (Pexp_override [])}
- | mod_longident DOT LBRACELESS field_expr_list opt_semi GREATERRBRACE
- { mkexp(Pexp_open(Fresh, mkrhs $1 1, mkexp (Pexp_override(List.rev $4))))}
- | mod_longident DOT LBRACELESS field_expr_list opt_semi error
+ | mod_longident DOT LBRACELESS field_expr_list GREATERRBRACE
+ { mkexp(Pexp_open(Fresh, mkrhs $1 1, mkexp (Pexp_override $4)))}
+ | mod_longident DOT LBRACELESS field_expr_list error
{ unclosed "{<" 3 ">}" 6 }
| simple_expr SHARP label
{ mkexp(Pexp_send($1, $3)) }
@@ -1412,10 +1412,14 @@ lbl_expr:
{ (mkrhs $1 1, exp_of_label $1 1) }
;
field_expr_list:
+ field_expr opt_semi { [$1] }
+ | field_expr SEMI field_expr_list { $1 :: $3 }
+;
+field_expr:
label EQUAL expr
- { [mkrhs $1 1,$3] }
- | field_expr_list SEMI label EQUAL expr
- { (mkrhs $3 3, $5) :: $1 }
+ { (mkrhs $1 1, $3) }
+ | label
+ { (mkrhs $1 1, exp_of_label (Lident $1) 1) }
;
expr_semi_list:
expr { [$1] }