KissInterp2 let list destructuring
Some checks failed
CI / test (push) Failing after 15s
CI / test-core (14, ubuntu-latest, 3.x, nodejs) (push) Failing after 40s
CI / test-core (14, ubuntu-latest, 3.x, interp) (push) Failing after 32s
CI / test-core (14, ubuntu-latest, 3.x, js) (push) Failing after 49s
CI / test-core (14, ubuntu-latest, 3.x, py) (push) Failing after 49s
CI / test-core (14, ubuntu-latest, 3.x, cpp) (push) Failing after 55s

This commit is contained in:
2025-11-14 14:49:08 -06:00
parent 6aead2330a
commit 50c0d673d7
3 changed files with 16 additions and 5 deletions

View File

@@ -136,12 +136,16 @@
(nextVar []
(if bindings
(let [v (bindings.shift)
vName (symbolNameValue v)
val (bindings.shift)]
(evalCC val ->val {
(dictSet scope vName val)
(nextVar)
}))
(evalCC val ->val
(case v.def
((Symbol vName)
(dictSet scope vName val))
((ListExp names)
(doFor [i s] (enumerate names)
(dictSet scope (symbolNameValue s) (nth val i))))
(never otherwise)))
(nextVar))
(evalCC (callSymbol "begin" body) ->result {
(localScopes.pop)
(cc result)

View File

@@ -49,5 +49,8 @@ class KissInterp2TestCase extends Test {
function testDestructive() {
_testDestructive();
}
function testListDestructure() {
_testListDestructure();
}
}

View File

@@ -63,3 +63,7 @@
(function _testDestructive []
(let [interp (new Interp)]
(assertEval 5 "(let [i 2] (+= i 3) i)")))
(function _testListDestructure []
(let [interp (new Interp)]
(assertEval [5 6 7] "(let [[a b c] [5 6 7]] [a b c])")))