diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-17 13:19:16 +0300 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-17 13:19:16 +0300 |
commit | 57c6323c15e257d4620f9d02a54e704d25bd2084 (patch) | |
tree | f71c6f9cc6a16f8a720652fa7593e46ae938cdfd | |
parent | a1ac176dd77ff9acaf62de825c24e3cdbd3bcdaa (diff) | |
download | myslip-57c6323c15e257d4620f9d02a54e704d25bd2084.tar.gz myslip-57c6323c15e257d4620f9d02a54e704d25bd2084.zip |
fix: repl erroring "let used as operator" with empty/nil inputs
this was fixed by transforming empty inputs to nil and not
transforming nil inputs to empty inputs.
-rw-r--r-- | src/main.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 30bd136..d7a2196 100644 --- a/src/main.rs +++ b/src/main.rs @@ -191,13 +191,15 @@ fn repl(mut binds: Vec<SExp>) -> Result<(), io::Error> { } let orig_expression = match parse_to_ast(&input) { - Ok(SCons(a, b)) if *b == Atom(Nil) => *a, + Ok(SCons(a, b)) if *b == Atom(Nil) && *a != Atom(Nil) => *a, + Ok(Atom(Nil)) => scons(Nil, Nil), Ok(t) => t, Err(e) => { println!("Syntax error: {}", e); continue; }, }; + if let Some((name, _value)) = orig_expression.clone().check_let() { let mut expr = scons(orig_expression.clone(), scons(Nil, Nil)); for i in 1..=binds.len() { |