aboutsummaryrefslogtreecommitdiff
path: root/src/sexp/subst.rs
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.kronqvist@iki.fi>2025-08-06 16:23:18 +0300
committerJoel Kronqvist <joel.kronqvist@iki.fi>2025-08-06 16:23:18 +0300
commit313c044b4a878a425aaca6554576f5154ace8ff9 (patch)
tree706bf5e34678622111a23c7045f667c1acbe7c6d /src/sexp/subst.rs
parent23b2028bdce46d02209fc2df70fc5468a8beffa8 (diff)
downloadmyslip-313c044b4a878a425aaca6554576f5154ace8ff9.tar.gz
myslip-313c044b4a878a425aaca6554576f5154ace8ff9.zip
Implemented let-bindings
Diffstat (limited to 'src/sexp/subst.rs')
-rw-r--r--src/sexp/subst.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/sexp/subst.rs b/src/sexp/subst.rs
index 87f9b50..4cfa48d 100644
--- a/src/sexp/subst.rs
+++ b/src/sexp/subst.rs
@@ -17,7 +17,14 @@ impl SExp {
/// ```
pub fn subst(self, name: &str, value: &SExp) -> SExp {
match self {
- SCons(a, b) => scons((*a).subst(name, value), (*b).subst(name, value)),
+ SCons(a, b) => {
+ if let Some((varname, _)) = a.clone().check_let() {
+ if &varname == name {
+ return SCons(a, b);
+ }
+ }
+ scons((*a).subst(name, value), (*b).subst(name, value))
+ },
Atom(Var(x)) if x == name => value.clone(),
t => t,
}