mirror of
https://github.com/HigherOrderCO/Bend.git
synced 2024-10-05 15:57:08 +03:00
Merge pull request #605 from HigherOrderCO/468-patterns-in-fun-rules-shouldnt-accept-unscoped-variables
#468 Patterns in "fun" rules should accept unscoped variables
This commit is contained in:
commit
8440fad2a4
@ -18,6 +18,7 @@ and this project does not currently adhere to a particular versioning scheme.
|
||||
|
||||
- Fix readback of numeric operations. ([#467][gh-467])
|
||||
- Propagate the "builtin" attribute of definitions when extracting functions from `bend` and `fold` syntax.
|
||||
- Panic while using unscoped variables on definition patterns. ([#468][gh-468])
|
||||
|
||||
### Added
|
||||
|
||||
@ -339,6 +340,7 @@ and this project does not currently adhere to a particular versioning scheme.
|
||||
[gh-465]: https://github.com/HigherOrderCO/Bend/issues/465
|
||||
[gh-466]: https://github.com/HigherOrderCO/Bend/issues/466
|
||||
[gh-467]: https://github.com/HigherOrderCO/Bend/issues/467
|
||||
[gh-468]: https://github.com/HigherOrderCO/Bend/issues/468
|
||||
[gh-470]: https://github.com/HigherOrderCO/Bend/issues/470
|
||||
[gh-475]: https://github.com/HigherOrderCO/Bend/issues/475
|
||||
[gh-478]: https://github.com/HigherOrderCO/Bend/issues/478
|
||||
|
@ -127,9 +127,19 @@ fn simplify_rule_match(
|
||||
fn irrefutable_fst_row_rule(args: Vec<Name>, rule: Rule) -> Term {
|
||||
let mut term = rule.body;
|
||||
for (arg, pat) in args.into_iter().zip(rule.pats.into_iter()) {
|
||||
let Pattern::Var(var) = pat else { unreachable!() };
|
||||
if let Some(var) = var {
|
||||
term = Term::Use { nam: Some(var), val: Box::new(Term::Var { nam: arg }), nxt: Box::new(term) };
|
||||
match pat {
|
||||
Pattern::Var(None) => {}
|
||||
Pattern::Var(Some(var)) => {
|
||||
term = Term::Use { nam: Some(var), val: Box::new(Term::Var { nam: arg }), nxt: Box::new(term) };
|
||||
}
|
||||
Pattern::Chn(var) => {
|
||||
term = Term::Let {
|
||||
pat: Box::new(Pattern::Chn(var)),
|
||||
val: Box::new(Term::Var { nam: arg }),
|
||||
nxt: Box::new(term),
|
||||
};
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
term
|
||||
|
3
tests/golden_tests/compile_file/def_pat_unscoped.bend
Normal file
3
tests/golden_tests/compile_file/def_pat_unscoped.bend
Normal file
@ -0,0 +1,3 @@
|
||||
add $a b = (+ $a b)
|
||||
|
||||
main = (add 9 4)
|
8
tests/snapshots/compile_file__def_pat_unscoped.bend.snap
Normal file
8
tests/snapshots/compile_file__def_pat_unscoped.bend.snap
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
source: tests/golden_tests.rs
|
||||
input_file: tests/golden_tests/compile_file/def_pat_unscoped.bend
|
||||
---
|
||||
@add = ($([+] $(a b)) (a b))
|
||||
|
||||
@main = a
|
||||
& @add ~ (9 (4 a))
|
Loading…
Reference in New Issue
Block a user