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
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:
@@ -136,12 +136,16 @@
|
|||||||
(nextVar []
|
(nextVar []
|
||||||
(if bindings
|
(if bindings
|
||||||
(let [v (bindings.shift)
|
(let [v (bindings.shift)
|
||||||
vName (symbolNameValue v)
|
|
||||||
val (bindings.shift)]
|
val (bindings.shift)]
|
||||||
(evalCC val ->val {
|
(evalCC val ->val
|
||||||
(dictSet scope vName val)
|
(case v.def
|
||||||
(nextVar)
|
((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 {
|
(evalCC (callSymbol "begin" body) ->result {
|
||||||
(localScopes.pop)
|
(localScopes.pop)
|
||||||
(cc result)
|
(cc result)
|
||||||
|
|||||||
@@ -49,5 +49,8 @@ class KissInterp2TestCase extends Test {
|
|||||||
function testDestructive() {
|
function testDestructive() {
|
||||||
_testDestructive();
|
_testDestructive();
|
||||||
}
|
}
|
||||||
|
function testListDestructure() {
|
||||||
|
_testListDestructure();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -63,3 +63,7 @@
|
|||||||
(function _testDestructive []
|
(function _testDestructive []
|
||||||
(let [interp (new Interp)]
|
(let [interp (new Interp)]
|
||||||
(assertEval 5 "(let [i 2] (+= i 3) i)")))
|
(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])")))
|
||||||
|
|||||||
Reference in New Issue
Block a user