diff options
Diffstat (limited to 'src/sexp/step.rs')
-rw-r--r-- | src/sexp/step.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/sexp/step.rs b/src/sexp/step.rs index 99925ac..9077401 100644 --- a/src/sexp/step.rs +++ b/src/sexp/step.rs @@ -352,9 +352,10 @@ impl SExp { return Ok(SExp::back_to_case(scrutinee.step()?, patarms)); } - let scrutinee = match scrutinee { - SCons(q, v) if *q == Atom(Quote) || *q == Atom(Vector) => *v, - t => t, + let (scrutinee, rest_pat_struct) = match scrutinee { + SCons(q, v) if *q == Atom(Quote) => (*v, Some(Quote)), + SCons(q, v) if *q == Atom(Vector) => (*v, Some(Vector)), + t => (t, None), }; for patarm in patarms { @@ -369,7 +370,14 @@ impl SExp { if let Some(ctx) = scrutinee.matches_pat(&pat) { for (name, value) in ctx { - arm = arm.subst(&name, &value); + arm = match name { + Var(name) => arm.subst(&name, &value), + RestPat(name) => match rest_pat_struct.clone() { + Some(kw) => arm.subst(&name, &scons(kw, value)), + None => arm.subst(&name, &value) + }, + _ => panic!("unreachable") + }; } return Ok(arm); } |