Skip to content

Batch of bug fixes (10 issues) - #26892

Open
Araq wants to merge 10 commits into
develfrom
araq-tersec-bugs1
Open

Araq wants to merge 10 commits into
develfrom
araq-tersec-bugs1

Conversation

@Araq

@Araq Araq commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

A batch of fixes for open issues, one commit per issue (best merged as rebase so each fix can be backported on its own).

🤖 Generated with Claude Code

Araq and others added 2 commits December 5, 2026 19:44
`putArgInto` did not know `nkCheckedFieldExpr`, the access of a field in a
case branch, so such an argument of an inline iterator was always copied
into a temporary, a 4 MB stack array per loop in the issue (stack overflow),
whereas the same field outside of a case branch is mapped directly like
any other field access path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ment

An inline iterator argument like `p()[].v` (a field behind the pointer that
a call returns) was copied as a whole into a temporary, the array of the
issue onto the stack, because its root is a call. #24093 already evaluated
only the pointer for `p()[]` itself; this now also covers field access
paths (`nkDotExpr`, `nkCheckedFieldExpr`) on top of such a deref: the
pointer goes into a temporary and the formal parameter is mapped to the path
rooted at it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Araq
Araq force-pushed the araq-tersec-bugs1 branch from 884a273 to b813100 Compare December 5, 2026 18:46
@Araq Araq changed the title Batch of bug fixes (17 issues) Batch of bug fixes (12 issues) Dec 5, 2026
Araq and others added 8 commits December 5, 2026 23:08
…body

When an inline iterator yields more than once, the loop body is duplicated
and `introduceNewLocalVars` gives the copy fresh local variables. A lambda
without an environment (at the top level it reads the global loop
variables directly) was not duplicated however:

* in a `var`/`let` initializer `transformVarSection` ran `transform`
  instead of `introduceNewLocalVars` over the value, and
* the `nkClosure` that wraps such a lambda was returned unchanged.

So every copy of the loop body used the first lambda, which accesses the
variables of the first copy: wrong results (#16417), or invalid C code
when the first copy is not generated at all, as for the `when nimvm`
branch (#25122, #15353).

Now the initializers of a duplicated body go through
`introduceNewLocalVars` and so does the lambda of an environment-less
closure, which copies the routine with the fresh variables mapped.

fixes #15353, fixes #16417

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…a re-exported module

importSymbol picks the first symbol named `x` from the interface of `m`
and, if it is not a single exportable symbol, iterates over all symbols
of that name. The loop then checked the kind of that *first* symbol
instead of the current one, so when the first hit was the re-exported
module `x` (skModule is not exportable) no overload was imported at all.
Check the kind of each iterated symbol instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…anch

Object construction with a runtime discriminator only looked for an
enclosing `case` statement when the discriminator value was a plain
symbol, so `case x.h of ...: K(h: x.h, ...)` fell through to the literal
comparison and reported a bogus branch conflict. The discriminator value
may now be any field access path (`a.b.c`, no dereference) whose root is
an immutable `let`/parameter; the enclosing `case` is found by structural
equality of the selector, and the immutability check is done on the root.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…aint

For `proc w[T: uint](v: T)` the call `w(0)` matched the constraint `uint`
only via a conversion, yet `T` was bound to the type of the argument
(`int`), contradicting the constraint. When the argument matches a
concrete (non-meta) constraint only by a conversion (isConvertible,
isIntConv, isFromIntLit), `T` is now bound to the constraint itself and
the argument is converted to it. Subtype matches still bind the
argument's type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Recursive type classes no longer crash the compiler; they are reported as
"illegal recursion in type".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…are on

Since #26509 the `nimln_`/`nimlf_` stack trace marker is written on its own
line after the `#line N` directive. A `#line` directive names the line that
immediately follows it, so the marker got line N and the statement itself
N+1: every statement compiled with `--lineDir:on --stackTrace:on` was
attributed to the next Nim line (C compiler/assembler diagnostics, debugger
line info, `__LINE__`), and multi-line asm reported lines past the end of
the file. Restate the `#line` directive after the marker.

Note that the assembler still counts the lines of the asm text itself, so an
asm string with N embedded `\n` written on one Nim line is reported as N
consecutive lines; that cannot be expressed with C `#line` directives.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…piler

`externalFileChanged` parsed the footprint of a `{.compile.}`d file with
`parseSecureHash(f.readLine())`, which raises EOFError on an empty file and
IndexDefect on a truncated one; both are left behind by an interrupted
build. Compare the stored line with the current hash instead, so anything
else simply counts as "changed" and the file is recompiled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Valgrind is clean for `addExitProc` with -d:useMalloc under orc, arc and
refc on devel; only the 2.0 line destroyed the exit proc seq before the
atexit handler read it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Araq Araq changed the title Batch of bug fixes (12 issues) Batch of bug fixes (10 issues) Dec 5, 2026
@Araq
Araq force-pushed the araq-tersec-bugs1 branch from b813100 to 78f8583 Compare December 5, 2026 22:10

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment