aboutsummaryrefslogtreecommitdiffhomepage
path: root/ide
diff options
context:
space:
mode:
authorGravatar Hugo Herbelin <Hugo.Herbelin@inria.fr>2017-02-01 15:56:45 +0100
committerGravatar Maxime Dénès <mail@maximedenes.fr>2017-03-24 12:22:21 +0100
commitf9a4ca41bc1313300f5f9b9092fe24825f435706 (patch)
treef2c6f100a01e26614a5ff6e7fe7471c7356b9de4 /ide
parent71cd2838bf3eb23a8f29df973d8012ebe2ec77b0 (diff)
Replacing "cast surgery" in LetIn by a proper field (see PR #404).
This is a patch fulfilling the relevant remark of Maxime that an explicit information at the ML type level would be better than "cast surgery" to carry the optional type of a let-in. There are a very few semantic changes. - a "(x:t:=c)" in a block of binders is now written in the more standard way "(x:=c:t)" - in notations, the type of a let-in is not displayed if not explicitly asked so. See discussion at PR #417 for more information.
Diffstat (limited to 'ide')
-rw-r--r--ide/texmacspp.ml9
1 files changed, 6 insertions, 3 deletions
diff --git a/ide/texmacspp.ml b/ide/texmacspp.ml
index e705e4e5a..e787e48bf 100644
--- a/ide/texmacspp.ml
+++ b/ide/texmacspp.ml
@@ -15,6 +15,7 @@ open Bigint
open Decl_kinds
open Extend
open Libnames
+open Constrexpr_ops
let unlock loc =
let start, stop = Loc.unloc loc in
@@ -228,9 +229,10 @@ and pp_decl_notation ((_, s), ce, sc) = (* don't know what it is for now *)
Element ("decl_notation", ["name", s], [pp_expr ce])
and pp_local_binder lb = (* don't know what it is for now *)
match lb with
- | CLocalDef ((_, nam), ce) ->
+ | CLocalDef ((loc, nam), ce, ty) ->
let attrs = ["name", string_of_name nam] in
- pp_expr ~attr:attrs ce
+ let value = match ty with Some t -> CCast (Loc.merge (constr_loc ce) (constr_loc t),ce, CastConv t) | None -> ce in
+ pp_expr ~attr:attrs value
| CLocalAssum (namll, _, ce) ->
let ppl =
List.map (fun (loc, nam) -> (xmlCst (string_of_name nam) loc)) namll in
@@ -465,7 +467,8 @@ and pp_expr ?(attr=[]) e =
[Element ("scrutinees", [], List.map pp_case_expr cel)] @
[pp_branch_expr_list bel]))
| CRecord (_, _) -> assert false
- | CLetIn (loc, (varloc, var), value, body) ->
+ | CLetIn (loc, (varloc, var), value, typ, body) ->
+ let value = match typ with Some t -> CCast (Loc.merge (constr_loc value) (constr_loc t),value, CastConv t) | None -> value in
xmlApply loc
(xmlOperator "let" loc ::
[xmlCst (string_of_name var) varloc; pp_expr value; pp_expr body])