From fb13f15c3933f35e92da1b4e39f6098fad4ddf14 Mon Sep 17 00:00:00 2001 From: dimgigov Date: Sat, 9 May 2026 20:34:26 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20+3=20tests=20(197/233,=2085%)=20?= =?UTF-8?q?=E2=80=94=20bigint=20overflow,=20var=5Fqmark=20indent,=20merge?= =?UTF-8?q?=20double=20discard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/emitter.nim | 5 +++-- src/macros.nim | 15 +++++++++++---- src/reader.nim | 10 ++++++++-- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/emitter.nim b/src/emitter.nim index 93b557b..a7a4a56 100644 --- a/src/emitter.nim +++ b/src/emitter.nim @@ -621,7 +621,7 @@ proc emitSpecialForm(items: seq[CljVal], indent: int): string = if bname.kind != ckSymbol: raise newException(EmitterError, "let binding name must be a symbol") addToScope(bname.symName) - lines.add(indentStr(indent + 1) & "let " & mangleName(bname.symName) & " = " & emitExpr(bval, 0)) + lines.add(indentStr(indent + 1) & "let " & mangleName(bname.symName) & " = " & emitExpr(bval, indent + 1)) bi += 2 let body = items[2..^1] for j, b in body: @@ -1557,7 +1557,8 @@ proc emitBlock(items: seq[CljVal], indent: int, useResult: bool = false): string let lastLine = if lastNl == -1: trimmed else: trimmed[lastNl+1..^1].strip() # Prepend discard before the first non-empty line if firstNl == -1: - if stripped.startsWith("let ") or stripped.startsWith("proc ") or stripped.startsWith("var "): + if stripped.startsWith("let ") or stripped.startsWith("proc ") or stripped.startsWith("var ") or + stripped.startsWith("discard "): code = indentStr(indent) & stripped else: code = indentStr(indent) & "discard " & stripped diff --git a/src/macros.nim b/src/macros.nim index 983998a..7832073 100644 --- a/src/macros.nim +++ b/src/macros.nim @@ -395,10 +395,17 @@ proc initMacros*() = let coll = bindings.items[1] let gs = cljSymbol(gensymName("ds_")) if name.kind == ckVector: - let destructured = cljList(@[cljSymbol("let"), name, cljList(@[cljSymbol("first"), gs])]) - let loopBody = cljList(@[cljSymbol("when"), gs] & @[destructured] & body) - let recurBody = cljList(@[cljSymbol("recur"), cljList(@[cljSymbol("rest"), gs])]) - let loopForm = cljList(@[cljSymbol("loop"), cljVector(@[gs, cljList(@[cljSymbol("seq"), gs])]), loopBody, recurBody]) + let seqGs = cljSymbol(gensymName("sq_")) + let tmpGs = cljSymbol(gensymName("tmp_")) + var innerBindings: seq[CljVal] = @[] + for j in 0..