Skip to content

Commit cda74fd

Browse files
committed
Partial fix for the case when two dirt params are equal
Closes #89
1 parent 4c47fe0 commit cda74fd

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

src/01-language/substitution.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ let add_dirt_var_coercion_e dirt_var dc =
330330
}
331331

332332
let add_dirt_var_coercion dirt_var dc sub =
333-
assert (dc = apply_sub_dirtcoer sub dc);
333+
assert (Coercion.equal_dirt_coercion dc (apply_sub_dirtcoer sub dc));
334334
merge (add_dirt_var_coercion_e dirt_var dc) sub
335335

336336
let add_dirt_substitution_e dirt_var dirt =

src/03-typechecker/unification.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,9 @@ and dirt_omega_step ~loc sub resolved unresolved w dcons =
293293
let w' = DirtCoercionParam.refresh w in
294294
let d2' = Dirt.Param.refresh d2 in
295295
let w_ty' =
296-
( { Dirt.effect_set = Effect.Set.empty; row = Dirt.Row.Param d1 },
296+
( (* In case d1 = d2, we need to substitute d1 as well *)
297+
Substitution.apply_substitutions_to_dirt dirt_sub
298+
{ Dirt.effect_set = Effect.Set.empty; row = Dirt.Row.Param d1 },
297299
{
298300
Dirt.effect_set = Effect.Set.union ops1 ops2;
299301
row = Dirt.Row.Param d2';

tests/valid.t

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@
116116
20
117117
- : int = 0
118118
======================================================================
119+
valid/test1.eff
120+
----------------------------------------------------------------------
121+
val testbug : ('a testtype -> 'a) => ('a testtype -> 'a) = <handler>
122+
======================================================================
119123
valid/test_equality.eff
120124
----------------------------------------------------------------------
121125
- : bool = true

tests/valid/test1.eff

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
(* https://github.com/matijapretnar/eff/issues/89 *)
2+
3+
effect A : unit
4+
effect B : unit
5+
6+
type 'a testtype = T of (('a testtype -> 'a) list)
7+
8+
let testbug = handler
9+
| effect A k -> fun (T ks) -> continue k () (T ((k ()) :: ks))
10+
| effect B k -> fun (T l) -> perform (Print "hello") ; continue k () (T l)

0 commit comments

Comments
 (0)