diff --git a/src/fun/transform/encode_adts.rs b/src/fun/transform/encode_adts.rs index 7a612f7a..4127f226 100644 --- a/src/fun/transform/encode_adts.rs +++ b/src/fun/transform/encode_adts.rs @@ -58,7 +58,7 @@ fn encode_ctr_num_scott<'a>(ctr_args: impl DoubleEndedIterator Term::rfold_lams(term, ctr_args.cloned().map(Some)) } -fn encode_num_scott_tag(tag : u32, ctr_name: &Name, source: Source) -> Definition { +fn encode_num_scott_tag(tag: u32, ctr_name: &Name, source: Source) -> Definition { let tag_nam = Name::new(format!("{ctr_name}/tag")); let rules = vec![Rule { pats: vec![], body: Term::Num { val: Num::U24(tag) } }]; Definition::new_gen(tag_nam.clone(), rules, source, true) diff --git a/src/imports/book.rs b/src/imports/book.rs index b491b85c..8ed6c0f5 100644 --- a/src/imports/book.rs +++ b/src/imports/book.rs @@ -200,6 +200,7 @@ impl ParseBook { name = Name::new(format!("__{}", name)); } + adt.name = name.clone(); adts_map.push((old_name, name.clone())); } diff --git a/tests/golden_tests/import_system/import_type.bend b/tests/golden_tests/import_system/import_type.bend index f2908c28..b79c33fa 100644 --- a/tests/golden_tests/import_system/import_type.bend +++ b/tests/golden_tests/import_system/import_type.bend @@ -1,6 +1,6 @@ from lib/MyOption import (MyOption, MyOption/bind, MyOption/wrap) -def main(): +def main() -> MyOption((u24, u24)): with MyOption: a <- MyOption/Some(1) b <- MyOption/Some(2) diff --git a/tests/golden_tests/import_system/lib/MyOption.bend b/tests/golden_tests/import_system/lib/MyOption.bend index c87f1700..f60de5fd 100644 --- a/tests/golden_tests/import_system/lib/MyOption.bend +++ b/tests/golden_tests/import_system/lib/MyOption.bend @@ -1,6 +1,8 @@ -type MyOption = (Some val) | (None) +type MyOption(A): + Some { val: A } + None -def MyOption/bind(val, nxt): +def MyOption/bind(val: MyOption(A), nxt: (Id -> Id) -> A -> MyOption(B)) -> MyOption(B): match val: case MyOption/Some: nxt = undefer(nxt) @@ -8,5 +10,5 @@ def MyOption/bind(val, nxt): case MyOption/None: return MyOption/None -def MyOption/wrap(val): +def MyOption/wrap(val: A) -> MyOption(A): return MyOption/Some(val)