Fix faulty unboxing

This commit is contained in:
Denis Merigoux 2022-07-22 16:18:55 +02:00
parent 522deb50c2
commit b7c468bd1e
No known key found for this signature in database
GPG Key ID: EE99DCFA365C3EE3
4 changed files with 25 additions and 5 deletions

View File

@ -146,8 +146,7 @@ let rec map_expr_top_down ~f e =
map_expr () ~f:(fun () -> map_expr_top_down ~f) (f e)
let map_expr_marks ~f e =
Bindlib.unbox
@@ map_expr_top_down ~f:(fun e -> Marked.(mark (f (get_mark e)) (unmark e))) e
map_expr_top_down ~f:(fun e -> Marked.(mark (f (get_mark e)) (unmark e))) e
let untype_expr e =
map_expr_marks ~f:(fun m -> Untyped { pos = D.mark_pos m }) e
@ -158,7 +157,7 @@ let untype_program prg =
D.scopes =
Bindlib.unbox
(D.map_exprs_in_scopes
~f:(fun e -> Bindlib.box (untype_expr e))
~f:(fun e -> untype_expr e)
~varf:translate_var prg.D.scopes);
}

View File

@ -104,10 +104,10 @@ val map_expr_top_down :
(** See [Dcalc.Ast.map_expr_top_down] *)
val map_expr_marks :
f:('m1 mark -> 'm2 mark) -> 'm1 marked_expr -> 'm2 marked_expr
f:('m1 mark -> 'm2 mark) -> 'm1 marked_expr -> 'm2 marked_expr Bindlib.box
(** See [Dcalc.Ast.map_expr_marks] *)
val untype_expr : 'm marked_expr -> Dcalc.Ast.untyped marked_expr
val untype_expr : 'm marked_expr -> Dcalc.Ast.untyped marked_expr Bindlib.box
val untype_program : 'm program -> Dcalc.Ast.untyped program
(** {1 Boxed constructors} *)

View File

@ -0,0 +1,8 @@
let Foo_29 : Foo_in{} → Foo_out{"bar_out": integer} =
λ (Foo_in_30: Foo_in{}) →
let bar_31 : integer =
try
handle_default_0 [] (λ (__32: any) → true) (λ (__33: any) → 0)
with EmptyError -> raise NoValueProvided in
Foo_out {"bar_out": bar_31} in
Foo_29

View File

@ -0,0 +1,13 @@
## Test
```catala
declaration scope Foo:
output bar content integer
scope Foo:
definition bar equals 0
```
```catala-test {id="Lcalc"}
catala Lcalc
```