Skip to content

Commit

Permalink
Correctly apply the import rename to ADTs
Browse files Browse the repository at this point in the history
  • Loading branch information
developedby committed Oct 6, 2024
1 parent 71e2600 commit ffbe560
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/imports/book.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ impl ParseBook {
name = Name::new(format!("__{}", name));
}

adt.name = name.clone();
adts_map.push((old_name, name.clone()));
}

Expand Down
2 changes: 1 addition & 1 deletion tests/golden_tests/import_system/import_type.bend
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
8 changes: 5 additions & 3 deletions tests/golden_tests/import_system/lib/MyOption.bend
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
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)
return nxt(val.val)
case MyOption/None:
return MyOption/None

def MyOption/wrap(val):
def MyOption/wrap(val: A) -> MyOption(A):
return MyOption/Some(val)

0 comments on commit ffbe560

Please sign in to comment.