From 901ca7905a9ad29a8e3492f6cc33cd9a6e28195c Mon Sep 17 00:00:00 2001 From: SirOlaf <34164198+SirOlaf@users.noreply.github.com> Date: Thu, 20 Aug 2026 18:11:31 +0200 Subject: [PATCH] IC: Do not serialize `nfHasComment` to nif (#26127) It causes non-deterministic behavior because it's process-local. --- compiler/ast2nif.nim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/ast2nif.nim b/compiler/ast2nif.nim index fe3ab0fb8a..6f4a0450a6 100644 --- a/compiler/ast2nif.nim +++ b/compiler/ast2nif.nim @@ -800,7 +800,11 @@ proc writeSymNode(w: var Writer; dest: var IcBuilder; n: PNode; sym: PSym) = dest.addSymUse pool.syms.getOrIncl(w.toNifSymName(sym)), info proc writeNodeFlags(dest: var IcBuilder; flags: set[TNodeFlag]) {.inline.} = - writeFlags(dest, flags) + # Comment text is not stored in NIF; `nfHasComment` is process-local + # (see `comment` in ast.nim). Emitting it made IC non-deterministic: + # `copyTree` from a parsed generic kept the comment (`"sh"`) while + # `copyTree` from a cache-loaded generic did not (`"s"`). + writeFlags(dest, flags - {nfHasComment}) template withNode(w: var Writer; dest: var IcBuilder; n: PNode; body: untyped) = dest.addParLe pool.tags.getOrIncl(toNifTag(n.kind)), trLineInfo(w, n.info)