-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(compiler): disambiguate OCaml record names derived from Catala s…
…truct
- Loading branch information
1 parent
43eb4de
commit 90e6b18
Showing
3 changed files
with
111 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
tests/test_scope/good/191_fix_record_name_confusion.catala_en
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
## Article | ||
|
||
```catala | ||
declaration scope ScopeA: | ||
context output a content boolean | ||
|
||
declaration scope ScopeB: | ||
context a content boolean | ||
scopeA scope ScopeA | ||
|
||
scope ScopeA: | ||
definition a equals true | ||
|
||
scope ScopeB: | ||
definition a equals scopeA.a | ||
``` | ||
|
||
```catala-test {id="OCaml"} | ||
catala OCaml | ||
``` |
68 changes: 68 additions & 0 deletions
68
tests/test_scope/good/output/191_fix_record_name_confusion.catala_en.OCaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
(** This file has been generated by the Catala compiler, do not edit! *) | ||
|
||
open Runtime | ||
|
||
[@@@ocaml.warning "-4-26-27-32-41-42"] | ||
|
||
module ScopeAOut = struct | ||
type t = { | ||
a_out: bool; | ||
} | ||
end | ||
|
||
module ScopeAIn = struct | ||
type t = { | ||
a_in: unit -> bool; | ||
} | ||
end | ||
|
||
module ScopeBOut = struct | ||
type t = unit | ||
end | ||
|
||
module ScopeBIn = struct | ||
type t = { | ||
a_in: unit -> bool; | ||
} | ||
end | ||
|
||
|
||
|
||
let scope_a (scope_a_in: ScopeAIn.t) : ScopeAOut.t = | ||
let a_: unit -> bool = scope_a_in.a_in in | ||
let a_: bool = (try | ||
(handle_default ([|(fun (_: _) -> a_ ())|]) | ||
(fun (_: _) -> true) | ||
(fun (_: _) -> | ||
handle_default | ||
([|(fun (_: _) -> | ||
handle_default ([||]) (fun (_: _) -> true) | ||
(fun (_: _) -> true))|]) | ||
(fun (_: _) -> false) | ||
(fun (_: _) -> raise EmptyError))) with | ||
EmptyError -> (raise (NoValueProvided | ||
{filename = "tests/test_scope/good/191_fix_record_name_confusion.catala_en"; | ||
start_line=5; start_column=18; | ||
end_line=5; end_column=19; law_headings=["Article"]}))) in | ||
{a_out = a_} | ||
|
||
let scope_b (scope_b_in: ScopeBIn.t) : ScopeBOut.t = | ||
let a_: unit -> bool = scope_b_in.a_in in | ||
let scope_a_dot_a_: unit -> bool = fun (_: unit) -> (raise EmptyError) in | ||
let result_: ScopeAOut.t = ((scope_a) {a_in = scope_a_dot_a_}) in | ||
let scope_a_dot_a_: bool = result_.a_out in | ||
let a_: bool = (try | ||
(handle_default ([|(fun (_: _) -> a_ ())|]) | ||
(fun (_: _) -> true) | ||
(fun (_: _) -> | ||
handle_default | ||
([|(fun (_: _) -> | ||
handle_default ([||]) (fun (_: _) -> true) | ||
(fun (_: _) -> scope_a_dot_a_))|]) | ||
(fun (_: _) -> false) | ||
(fun (_: _) -> raise EmptyError))) with | ||
EmptyError -> (raise (NoValueProvided | ||
{filename = "tests/test_scope/good/191_fix_record_name_confusion.catala_en"; | ||
start_line=8; start_column=11; | ||
end_line=8; end_column=12; law_headings=["Article"]}))) in | ||
() |