fix: 18 bugs across interpreter, reader, emitter, and runtime

- cljMinMax now handles float and mixed int/float arguments
- cljType* covers ckSet, ckTransient, ckAgent
- cljConj and cljVec return vectors instead of lists
- rem uses truncated division semantics (matches Clojure)
- range with negative step terminates correctly
- reduce of empty collection with no init errors instead of returning nil
- swap! extra args flatten correctly
- remove duplicate not definition (dead code)
- ratio literals (1/5) parse correctly
- scientific notation uses correct variable (numTok not tok)
- readSet returns proper set value instead of (set [...]) form
- TCP REPL catches specific exceptions instead of bare except
- initBuiltinMacros guards against duplicate registration
- doseq :while clause no longer generates dead code or infinite loop
- emitter resets all global state on each emitProgram call
- pushLeaf fills gaps with internal nodes instead of nil children

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-20 12:25:53 +03:00
parent 7cb8aa1ee0
commit 11fca52282
7 changed files with 91 additions and 42 deletions
+7
View File
@@ -2394,6 +2394,13 @@ proc emitProgramInternal(forms: seq[CljVal]): string =
scopeStack = @[]
pushScope()
requiredImports = initHashSet[string]()
loopStack = @[]
loopResultVar = ""
nsAliases = @[]
libNsPrefixes = @[]
definedGlobals = initHashSet[string]()
definedFnArities = initTable[string, int]()
multiArityFns = initHashSet[string]()
var headerLines: seq[string] = @[
"# Generated by Bara Lang",
"import cljnim_runtime",