Skip to content

Commit 853b4d7

Browse files
panglesdjonludlam
authored andcommitted
fix wrong location taken on types
Signed-off-by: Paul-Elliot <[email protected]>
1 parent 4b4e8dd commit 853b4d7

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

src/loader/ident_env.cppo.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,11 @@ let rec extract_structure_tree_items : bool -> Typedtree.structure_item list ->
303303
let open Typedtree in
304304
match items with
305305
#if OCAML_VERSION < (4,3,0)
306-
| { str_desc = Tstr_type decls; str_loc; _ } :: rest ->
306+
| { str_desc = Tstr_type decls; _ } :: rest ->
307307
#else
308-
| { str_desc = Tstr_type (_, decls); str_loc; _ } :: rest -> (* TODO: handle rec_flag *)
308+
| { str_desc = Tstr_type (_, decls); _ } :: rest -> (* TODO: handle rec_flag *)
309309
#endif
310-
List.map (fun decl -> `Type (decl.typ_id, hide_item, Some str_loc))
310+
List.map (fun decl -> `Type (decl.typ_id, hide_item, Some decl.typ_loc))
311311
decls @ extract_structure_tree_items hide_item rest
312312

313313
#if OCAML_VERSION < (4,14,0)

test/sources/source.t/a.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ module X : sig
2828
end = struct
2929
type t = int
3030
end
31+
32+
type a1 = int
33+
and a2 = a1

test/sources/source.t/run.t

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ Files containing some values:
3131
end = struct
3232
type t = int
3333
end
34+
35+
type a1 = int
36+
and a2 = a1
3437

3538
Source pages require a parent:
3639

@@ -134,6 +137,14 @@ Source links generated in the documentation:
134137
<div class="spec module anchored" id="module-X">
135138
<a href="#module-X" class="anchor"></a>
136139
<a href="../root/source/a.ml.html#module-X" class="source_link">Source
140+
--
141+
<div class="spec type anchored" id="type-a1">
142+
<a href="#type-a1" class="anchor"></a>
143+
<a href="../root/source/a.ml.html#def_24" class="source_link">Source</a>
144+
--
145+
<div class="spec type anchored" id="type-a2">
146+
<a href="#type-a2" class="anchor"></a>
147+
<a href="../root/source/a.ml.html#def_25" class="source_link">Source</a>
137148

138149
Ids generated in the source code:
139150

@@ -168,6 +179,9 @@ Ids generated in the source code:
168179
id="L28"
169180
id="L29"
170181
id="L30"
182+
id="L31"
183+
id="L32"
184+
id="L33"
171185
id="type-t"
172186
id="type-truc"
173187
id="value-{x}2"
@@ -189,3 +203,5 @@ Ids generated in the source code:
189203
id="module-X"
190204
id="module-X.type-t"
191205
id="module-X.type-t"
206+
id="def_24"
207+
id="def_25"

0 commit comments

Comments
 (0)