summaryrefslogtreecommitdiff
path: root/parsing/depend.ml
diff options
context:
space:
mode:
authorGabriel Scherer <gabriel.scherer@gmail.com>2018-07-14 23:10:39 +0200
committerGabriel Scherer <gabriel.scherer@gmail.com>2018-08-20 19:57:47 +0200
commit85785b173ab1083472998bd1255b73843f536e57 (patch)
tree38e89f0b47aa5d08f35777a2bdd14eef21b4e9c3 /parsing/depend.ml
parent4d3088cdbe5ceea0fd03bb29c3d4856e8ed995d8 (diff)
downloadocaml-85785b173ab1083472998bd1255b73843f536e57.tar.gz
parsetree: make sure that all nodes that store attributes also store a location
Florian Angeletti and myself ran into a problem when trying to use attributes for ellision of parts of manual example. We wanted to be turn any ast-node marked with the [@ellipsis] attribute into "..." in the rendering of the corresponding code block, but for this we need the location of the attributed node, and it turns out that some constructions supported attributes without carrying a location: - Rtag in row_field - Otag in object_field - type_exception record - type_extension record We added locations in all those positions, guaranteeing the invariant that all nodes to which attributes can be attached have a precise position.
Diffstat (limited to 'parsing/depend.ml')
-rw-r--r--parsing/depend.ml6
1 files changed, 4 insertions, 2 deletions
diff --git a/parsing/depend.ml b/parsing/depend.ml
index b421e24604..4c0d720d18 100644
--- a/parsing/depend.ml
+++ b/parsing/depend.ml
@@ -104,13 +104,15 @@ let rec add_type bv ty =
| Ptyp_constr(c, tl) -> add bv c; List.iter (add_type bv) tl
| Ptyp_object (fl, _) ->
List.iter
- (function Otag (_, _, t) -> add_type bv t
+ (fun {pof_desc; _} -> match pof_desc with
+ | Otag (_, _, t) -> add_type bv t
| Oinherit t -> add_type bv t) fl
| Ptyp_class(c, tl) -> add bv c; List.iter (add_type bv) tl
| Ptyp_alias(t, _) -> add_type bv t
| Ptyp_variant(fl, _, _) ->
List.iter
- (function Rtag(_,_,_,stl) -> List.iter (add_type bv) stl
+ (fun {prf_desc; _} -> match prf_desc with
+ | Rtag(_,_,_,stl) -> List.iter (add_type bv) stl
| Rinherit sty -> add_type bv sty)
fl
| Ptyp_poly(_, t) -> add_type bv t