diff --git a/CHANGELOG.md b/CHANGELOG.md index 6799e5317..55d820753 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ and this project does not currently adhere to a particular versioning scheme. - Expand references to functions generated by the `float_combinators` pass inside the main function. ([#642][gh-642]) - Expand references inside constructors in the main function. ([#643][gh-643]) - Fix readback when hvm net has `a{n}` or `x{n}` vars. ([#659][gh-659]) +- Fix imported constructors not being updated to Constructor expression. ([#674][gh-674]) +- Fix parse error on parenthesized eraser. ([#675][gh-675]) ### Added @@ -420,4 +422,6 @@ and this project does not currently adhere to a particular versioning scheme. [gh-648]: https://github.com/HigherOrderCO/Bend/issues/648 [gh-657]: https://github.com/HigherOrderCO/Bend/issues/657 [gh-659]: https://github.com/HigherOrderCO/Bend/pull/659 +[gh-674]: https://github.com/HigherOrderCO/Bend/issues/674 +[gh-675]: https://github.com/HigherOrderCO/Bend/issues/675 [Unreleased]: https://github.com/HigherOrderCO/Bend/compare/0.2.36...HEAD diff --git a/src/fun/parser.rs b/src/fun/parser.rs index 3046070f3..97c9e8267 100644 --- a/src/fun/parser.rs +++ b/src/fun/parser.rs @@ -482,6 +482,10 @@ impl<'a> TermParser<'a> { return Ok(Term::Fan { fan: FanKind::Tup, tag: tag.unwrap_or(Tag::Static), els }); } + if opr == Op::MUL && self.try_consume(")") { + return Ok(Term::Era); + } + // Opr unexpected_tag(self)?; let fst = self.parse_term()?; diff --git a/src/imports/book.rs b/src/imports/book.rs index 10ad64c8e..3c2c7b7b8 100644 --- a/src/imports/book.rs +++ b/src/imports/book.rs @@ -161,6 +161,7 @@ impl ParseBook { let adts = std::mem::take(&mut self.adts); let mut new_adts = IndexMap::new(); let mut ctrs_map = IndexMap::new(); + let mut new_ctrs = IndexMap::new(); // Rename the ADTs and constructors to their canonical name, // starting with `__` if not imported by the main book. @@ -182,6 +183,7 @@ impl ParseBook { ctr_name = Name::new(format!("__{}", ctr_name)); } + new_ctrs.insert(ctr_name.clone(), name.clone()); ctrs_map.insert(ctr, ctr_name.clone()); adt.ctrs.insert(ctr_name, f); } @@ -201,6 +203,7 @@ impl ParseBook { } self.adts = new_adts; + self.ctrs = new_ctrs; } /// Apply the necessary naming transformations to the book definitions, diff --git a/tests/golden_tests/import_system/import_ctr_syntax.bend b/tests/golden_tests/import_system/import_ctr_syntax.bend new file mode 100644 index 000000000..c1303a051 --- /dev/null +++ b/tests/golden_tests/import_system/import_ctr_syntax.bend @@ -0,0 +1,3 @@ +from lib/ctr_type import Ctr + +main = (Ctr/Foo 2 3) diff --git a/tests/golden_tests/import_system/lib/ctr_type.bend b/tests/golden_tests/import_system/lib/ctr_type.bend new file mode 100644 index 000000000..649bad49a --- /dev/null +++ b/tests/golden_tests/import_system/lib/ctr_type.bend @@ -0,0 +1,6 @@ +# Test issue #674 +type Ctr: + Foo { x, y } + +def Ctr/wrap(x): + return Ctr/Foo { x: x, y: 0 } diff --git a/tests/golden_tests/parse_file/era.bend b/tests/golden_tests/parse_file/era.bend new file mode 100644 index 000000000..88a4b50ba --- /dev/null +++ b/tests/golden_tests/parse_file/era.bend @@ -0,0 +1 @@ +(Main) = (*) diff --git a/tests/snapshots/import_system__import_ctr_syntax.bend.snap b/tests/snapshots/import_system__import_ctr_syntax.bend.snap new file mode 100644 index 000000000..2e3e8eaa0 --- /dev/null +++ b/tests/snapshots/import_system__import_ctr_syntax.bend.snap @@ -0,0 +1,5 @@ +--- +source: tests/golden_tests.rs +input_file: tests/golden_tests/import_system/import_ctr_syntax.bend +--- +λa (a lib/ctr_type/Ctr/Foo/tag 2 3) diff --git a/tests/snapshots/parse_file__era.bend.snap b/tests/snapshots/parse_file__era.bend.snap new file mode 100644 index 000000000..3f2e17e1a --- /dev/null +++ b/tests/snapshots/parse_file__era.bend.snap @@ -0,0 +1,5 @@ +--- +source: tests/golden_tests.rs +input_file: tests/golden_tests/parse_file/era.bend +--- +(Main) = *