diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-22 22:28:34 +0300 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-22 22:28:34 +0300 |
commit | df65d1ec5b2c5a338b121c575b0dac321d15b299 (patch) | |
tree | 9cfcccd3e488602ce13fb5f40a95b8292587c87c | |
parent | 55ff37ab09d4a5374ed02089a0d3fd6b8300c20e (diff) | |
download | myslip-df65d1ec5b2c5a338b121c575b0dac321d15b299.tar.gz myslip-df65d1ec5b2c5a338b121c575b0dac321d15b299.zip |
fix: removed unneccessary lowering from SCons(x, Nil) to x when getting matched arms
-rw-r--r-- | src/sexp/step.rs | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/sexp/step.rs b/src/sexp/step.rs index 3168c5b..1a336e3 100644 --- a/src/sexp/step.rs +++ b/src/sexp/step.rs @@ -296,7 +296,7 @@ impl SExp { /// let expshould = parse_to_ast("case 3 (3 true) (_ false)"); /// assert_eq!(exp, expshould); /// let exp = exp.and_then(|e| e.step()); - /// assert_eq!(exp, Ok(Atom(True))); + /// assert_eq!(exp, Ok(scons(Atom(True), Nil))); /// /// let exp = "case (coprod Bool (+ 1 2)) ((inl b) (if b 1 0)) ((inr x) (- x 1))"; /// let exp = parse_to_ast(exp); @@ -304,7 +304,7 @@ impl SExp { /// let expshould = parse_to_ast("case (coprod Bool 3) ((inl b) (if b 1 0)) ((inr x) (- x 1))"); /// assert_eq!(exp, expshould); /// let exp = exp.and_then(|e| e.step()); - /// assert_eq!(exp, Ok(scons(Sub, scons(3, scons(1, Nil))))); + /// assert_eq!(exp, parse_to_ast("(- 3 1)")); /// ``` /// /// Shadowing: @@ -371,10 +371,7 @@ impl SExp { SCons(pat, arm) => Ok((*pat, *arm)), _ => Err("unreachable after type checking".to_string()) }?; - let mut arm = match arm { - SCons(x, n) if *n == Atom(Nil) => *x, - t => t, - }; + let mut arm = arm; if let Some(ctx) = scrutinee.matches_pat(&pat) { for (name, value) in ctx { |