fix(runtime): cljAssocIn handles vectors as keys path

fix(emitter): remove contains? from special-forms list (handled elsewhere)
This commit is contained in:
2026-05-12 18:55:27 +03:00
parent 7adace4ee1
commit 014a192c5d
2 changed files with 10 additions and 7 deletions
+9 -6
View File
@@ -2080,12 +2080,15 @@ proc cljUpdate*(m: CljVal, key: CljVal, f: CljVal, extra: seq[CljVal] = @[]): Cl
else: raise newException(CatchableError, "update requires a function")
proc cljAssocIn*(m: CljVal, keys: CljVal, val: CljVal): CljVal =
if keys.isNil or keys.kind != ckList or keys.listItems.len == 0:
return m
if keys.listItems.len == 1:
return cljAssoc(m, keys.listItems[0], val)
let firstKey = keys.listItems[0]
let restKeys = cljList(keys.listItems[1..^1])
if keys.isNil: return m
let isList = keys.kind == ckList or keys.kind == ckVector
if not isList: return m
let keyItems = if keys.kind == ckList: keys.listItems else: keys.vecData.toSeq
if keyItems.len == 0: return m
if keyItems.len == 1:
return cljAssoc(m, keyItems[0], val)
let firstKey = keyItems[0]
let restKeys = cljList(keyItems[1..^1])
let inner = cljGet(m, firstKey)
let updated = cljAssocIn(inner, restKeys, val)
cljAssoc(m, firstKey, updated)
+1 -1
View File
@@ -2107,7 +2107,7 @@ proc emitSpecialForm(items: seq[CljVal], indent: int, needsValue: bool = false):
"to-array", "into-array", "vector", "rand", "rand-int",
"rand-nth", "random-sample",
"assoc", "dissoc", "get", "get-in", "update", "assoc-in",
"contains?", "select-keys",
"select-keys",
"disj", "peek", "pop",
"transduce", "ex-info",
"compare", "subvec",