Skip to content

Commit 7b0bb6b

Browse files
committed
merge fix
2 parents cde3f7a + 062397c commit 7b0bb6b

File tree

3 files changed

+60
-30
lines changed

3 files changed

+60
-30
lines changed

src/haz3lcore/projectors/implementations/HTMLProj.re

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@ module M: Projector = {
251251
Node.div(
252252
~attrs=[
253253
Attr.classes(["html-proj-resize-handle"]),
254-
Attr.on_pointerdown((evt: Js_of_ocaml.Js.t(Js_of_ocaml.Dom_html.pointerEvent)) => {
254+
Attr.on_pointerdown(
255+
(evt: Js_of_ocaml.Js.t(Js_of_ocaml.Dom_html.pointerEvent)) => {
255256
resize_cols := model.ui.cols;
256257
resize_rows := model.ui.rows;
257258
let target =
@@ -271,17 +272,24 @@ module M: Projector = {
271272
Attr.on_mousemove(evt => {
272273
switch (wrapper_ref^) {
273274
| Some(wrapper) =>
274-
let container = Js_of_ocaml.Js.Unsafe.coerce(wrapper)##.parentNode;
275+
let container =
276+
Js_of_ocaml.Js.Unsafe.coerce(wrapper)##.parentNode;
275277
let rect = container##getBoundingClientRect();
276278
let left: float = rect##.left;
277279
let top: float = rect##.top;
278280
let e = Js_of_ocaml.Js.Unsafe.coerce(evt);
279281
let client_x: float = float_of_int(e##.clientX);
280282
let client_y: float = float_of_int(e##.clientY);
281283
let new_cols =
282-
max(8, int_of_float(floor((client_x -. left) /. px_per_col^)));
284+
max(
285+
8,
286+
int_of_float(floor((client_x -. left) /. px_per_col^)),
287+
);
283288
let new_rows =
284-
max(3, int_of_float(floor((client_y -. top) /. px_per_row^)));
289+
max(
290+
3,
291+
int_of_float(floor((client_y -. top) /. px_per_row^)),
292+
);
285293
if (new_cols != resize_cols^ || new_rows != resize_rows^) {
286294
resize_cols := new_cols;
287295
resize_rows := new_rows;
@@ -290,9 +298,10 @@ module M: Projector = {
290298
Effect.Ignore;
291299
};
292300
| None => Effect.Ignore
293-
};
301+
}
294302
}),
295-
Attr.on_pointerup((evt: Js_of_ocaml.Js.t(Js_of_ocaml.Dom_html.pointerEvent)) => {
303+
Attr.on_pointerup(
304+
(evt: Js_of_ocaml.Js.t(Js_of_ocaml.Dom_html.pointerEvent)) => {
296305
let target =
297306
evt##.currentTarget
298307
|> Js_of_ocaml.Js.Opt.get(_, _ => failwith("no target"));

src/language/dynamics/transition/Ascriptions.re

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,10 @@ let rec transition = (~recursive=false, d: DHExp.t): option(DHExp.t) => {
5252
The ORIGINAL compact type `t` is preserved in newly created Asc nodes. */
5353
let t_resolved = Typ.weak_head_normalize(ctx, t);
5454
switch (DHExp.term_of(e), Typ.term_of(Typ.unroll(t_resolved))) {
55-
| (Asc(e, t'), t)
55+
| (Asc(e, t'), _)
5656
// This is only necessary because sometimes we add two ascriptions and aren't marking it as a non-value
57-
when
58-
Typ.is_consistent(ctx, Typ.unroll(t |> Typ.temp), Typ.unroll(t')) =>
59-
switch (Typ.meet(ctx, Typ.unroll(t |> Typ.temp), Typ.unroll(t'))) {
57+
when Typ.is_consistent(ctx, Typ.unroll(t), Typ.unroll(t')) =>
58+
switch (Typ.meet(ctx, Typ.unroll(t), Typ.unroll(t'))) {
6059
| Some(t) => Some(recur(Asc(e, t) |> DHExp.fresh))
6160
| None => None //TODO This is an impossible case since we checked consistency
6261
}
@@ -152,26 +151,26 @@ let rec transition = (~recursive=false, d: DHExp.t): option(DHExp.t) => {
152151
|> DHExp.fresh,
153152
),
154153
);
155-
| (If(cond, e1, e2), t) =>
154+
| (If(cond, e1, e2), _) =>
156155
Some(
157156
IdTagged.fast_copy(
158157
DHExp.rep_id(e),
159158
If(
160159
recur(cond),
161-
recur(Asc(e1, t |> Typ.temp) |> DHExp.fresh),
162-
recur(Asc(e2, t |> Typ.temp) |> DHExp.fresh),
160+
recur(Asc(e1, t) |> DHExp.fresh),
161+
recur(Asc(e2, t) |> DHExp.fresh),
163162
)
164163
|> DHExp.fresh,
165164
),
166165
)
167-
| (Match(scrut, rules), t) =>
166+
| (Match(scrut, rules), _) =>
168167
Some(
169168
IdTagged.fast_copy(
170169
DHExp.rep_id(e),
171170
Match(
172171
scrut,
173172
List.map(
174-
((p, body)) => (p, Asc(body, t |> Typ.temp) |> DHExp.fresh),
173+
((p, body)) => (p, Asc(body, t) |> DHExp.fresh),
175174
rules,
176175
),
177176
)

test/evaluator/Test_Evaluator_Sum_Types.re

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,47 @@ let tests = (
2828
)
2929
}),
3030
test_case(
31-
"Constructors can pass through consistent ascriptions", `Quick, () => {
32-
evaluation_test(
33-
{|A : (+A +B) : (+A + ?)|},
34-
constructor(
35-
"A",
36-
Some(
31+
"Constructors can pass through consistent ascriptions",
32+
`Quick,
33+
() => {
34+
evaluation_test(
35+
{|A : (+A +B) : (+A + ?)|},
36+
constructor(
37+
"A",
3738
Some(
38-
Typ.(
39-
sum([
40-
Variant("A", ConstructorMap.empty_variant_ann, None),
41-
Variant("B", ConstructorMap.empty_variant_ann, None),
42-
])
39+
Some(
40+
Typ.(
41+
sum([
42+
Variant("A", ConstructorMap.empty_variant_ann, None),
43+
Variant("B", ConstructorMap.empty_variant_ann, None),
44+
])
45+
),
4346
),
4447
),
4548
),
46-
),
47-
elaborate(parse_exp({|A : (+A +B) : (+A + ?)|})),
48-
)
49-
}),
49+
elaborate(parse_exp({|A : (+A +B) : (+A + ?)|})),
50+
);
51+
evaluation_test(
52+
"Ascriptions don't do unnecessary unrolling",
53+
asc(
54+
empty_hole(),
55+
Typ.rec_(
56+
TPat.var("X"),
57+
Typ.sum([
58+
Variant(
59+
"A",
60+
ConstructorMap.empty_variant_ann,
61+
Some(Typ.var("X")),
62+
),
63+
]),
64+
),
65+
),
66+
elaborate(
67+
parse_exp("(if true then ? else ?) : (rec X -> + A(X))"),
68+
),
69+
);
70+
},
71+
),
5072
test_case(
5173
"Constructors don't pass through inconsistent ascriptions", `Quick, () => {
5274
evaluation_test(

0 commit comments

Comments
 (0)