Skip to content

Commit 2112a4a

Browse files
authored
Merge pull request #1724 from cryspen/engine-fix-owner-hints
fix(engine): fix owner_id
2 parents d6f9f61 + d7ab57f commit 2112a4a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

engine/lib/span.ml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,12 @@ type owner_id = OwnerId of int
9797
[@@deriving show, yojson, sexp, compare, eq, hash]
9898

9999
let owner_id_list = ref []
100+
let owner_id_list_len = ref 0
100101

101102
let fresh_owner_id (owner : Types.def_id) : owner_id =
102-
let next_id = OwnerId (List.length !owner_id_list) in
103+
let next_id = OwnerId !owner_id_list_len in
103104
owner_id_list := owner :: !owner_id_list;
105+
owner_id_list_len := !owner_id_list_len + 1;
104106
next_id
105107

106108
(** This state changes the behavior of `of_thir`: the hint placed into this
@@ -151,7 +153,8 @@ let default = { id = 0; data = []; owner_hint = None }
151153
let owner_hint span =
152154
span.owner_hint
153155
|> Option.map ~f:(fun (OwnerId id) ->
154-
Option.value_exn (List.nth !owner_id_list id))
156+
Option.value_exn
157+
(List.nth !owner_id_list (!owner_id_list_len - id - 1)))
155158

156159
let to_span2 span : Types.span2 =
157160
{

0 commit comments

Comments
 (0)