Skip to content

Commit

Permalink
Fix lambda body parsing (#707)
Browse files Browse the repository at this point in the history
  • Loading branch information
imaqtkatt authored Sep 5, 2024
1 parent f3be26b commit a5054e4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project does not currently adhere to a particular versioning scheme.
- Fix imported constructors not being updated to Constructor expression. ([#674][gh-674])
- Fix parse error on parenthesized eraser. ([#675][gh-675])
- Fix IO/FS/read_line when the line ends with a EOF. ([#638][gh-638])
- Fix lambda body being parsed as tuple in imp syntax. ([#706][gh-706])

### Added

Expand Down Expand Up @@ -419,6 +420,7 @@ and this project does not currently adhere to a particular versioning scheme.
[gh-621]: https://github.com/HigherOrderCO/Bend/issues/621
[gh-623]: https://github.com/HigherOrderCO/Bend/issues/623
[gh-629]: https://github.com/HigherOrderCO/Bend/issues/629
[gh-638]: https://github.com/HigherOrderCO/Bend/issues/638
[gh-642]: https://github.com/HigherOrderCO/Bend/issues/642
[gh-643]: https://github.com/HigherOrderCO/Bend/issues/643
[gh-648]: https://github.com/HigherOrderCO/Bend/issues/648
Expand All @@ -427,5 +429,5 @@ and this project does not currently adhere to a particular versioning scheme.
[gh-673]: https://github.com/HigherOrderCO/Bend/pull/673
[gh-674]: https://github.com/HigherOrderCO/Bend/issues/674
[gh-675]: https://github.com/HigherOrderCO/Bend/issues/675
[gh-638]: https://github.com/HigherOrderCO/Bend/issues/638
[gh-706]: https://github.com/HigherOrderCO/Bend/issues/706
[Unreleased]: https://github.com/HigherOrderCO/Bend/compare/0.2.36...HEAD
2 changes: 1 addition & 1 deletion src/imp/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl<'a> PyParser<'a> {
}
}
let names = self.list_like(|p| parse_lam_var(p), "", ":", ",", false, 1)?;
let bod = self.parse_expr(inline, true)?;
let bod = self.parse_expr(inline, false)?;
Ok(Expr::Lam { names, bod: Box::new(bod) })
} else if self.starts_with("(") {
self.advance_one();
Expand Down
17 changes: 17 additions & 0 deletions tests/golden_tests/run_file/filter_bool_id.bend
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
type Bool:
T
F

def filter(f, ls):
match ls:
case List/Nil:
return List/Nil
case List/Cons:
match f(ls.head):
case Bool/T:
return List/Cons(ls.head, filter(f, ls.tail))
case Bool/F:
return filter(f, ls.tail)

def main:
return filter(lambda x: x, [Bool/T])
9 changes: 9 additions & 0 deletions tests/snapshots/run_file__filter_bool_id.bend.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_file/filter_bool_id.bend
---
NumScott:
[Bool/T]

Scott:
[Bool/T]

0 comments on commit a5054e4

Please sign in to comment.