Skip to content

Commit 90592b5

Browse files
committed
fix: in Syntactic.non_proper make all cases uniform
In the case of variable y point to t and variable x is not assign, x and y were not merge, while if x point to s, there are merge. We make the handling uniform by always merging the variable.
1 parent 469bf4e commit 90592b5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/unification/Syntactic.ml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ and quasi_solved env stack x s =
182182

183183
(* Non proper equations
184184
'x ≡ 'y
185-
To include a non propre equations, we need to be sure that the dependency created between variable is a DAG. Therefore, we use the Variable.get_most_general, to order the dependency.
185+
To include a non proper equations, we need to be sure that the dependency created between variable is a DAG. Therefore, we use the Variable.get_most_general, to order the dependency.
186186
*)
187187
and non_proper env stack (x : Variable.t) (y : Variable.t) =
188188
Trace.with_span ~__FUNCTION__ ~__LINE__ ~__FILE__ __FUNCTION__ (fun _sp ->
@@ -196,8 +196,12 @@ and non_proper env stack (x : Variable.t) (y : Variable.t) =
196196
let* () = if Variable.equal z' x' then Done else attach env x' tz in
197197
let* () = if Variable.equal z' y' then Done else attach env y' tz in
198198
process_stack env stack
199-
| V x', E (_, t) | E (_, t), V x' ->
200-
let* () = attach env x' t in
199+
| V x', E (y', t) | E (y', t), V x' ->
200+
let z' = Variable.get_most_general (fun f -> Env.gen f env) [x'; y'] in
201+
let tz = Type.var (Env.tyenv env) z' in
202+
let* () = if Variable.equal z' x' then Done else attach env x' tz in
203+
let* () = if Variable.equal z' y' then Done else attach env y' tz in
204+
let* () = attach env z' t in
201205
process_stack env stack
202206
| E (x', s), E (y', t) ->
203207
let z' = Variable.get_most_general (fun f -> Env.gen f env) [x'; y'] in

0 commit comments

Comments
 (0)