Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lambda body parsing #707

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]
Loading