Nim 2.4.2
Nim 2.4.2 was tagged on November 12, 2026. It is a maintenance release on the 2.4 line, and the changelog that ships with it documents the 2.4 series as a whole: a set of compiler, language and standard library changes that a project coming from 2.2 needs to read before it upgrades.
Overview
The release keeps the package layout and toolchain behavior of 2.4, which means choosenim and distro packages can move to 2.4.2 without a configuration rewrite. The interesting material sits one layer down: defaults that changed, deprecations that now bite, and two language features behind experimental switches.
Breaking Changes
- Solaris and illumos are separate targets.
--os:solarisand--os:illumosboth definesunos,posixandunix, but illumos no longer definessolaris. Code shared by both should testdefined(sunos). --compileOnlyno longer implies host C compiler settings and no longer omits the/* Compiled for ... */header, so cross compilation settings are honored. The old behavior is available through the new--mergeableCcodeswitch.- Float round-trip formatting is the default.
-d:nimPreviewFloatRoundtripmoved out of preview:system.addFloatandsystem.$now produce minimal, correctly rounded representations using the Dragonbox algorithm.-d:nimLegacySprintfemulates the old output. tables.getOrDefaultrenamed its parameter fromdefaulttodef, because the old name collided withsystem.default. Call sites usingdefault = ...by name must be edited.- Bare
except:panics onDefect. Useexcept Exception:orexcept Defect:.--legacy:noPanicOnExceptexists as a transition flag. - Array iteration yields
lent T.itemsfor arrays now behaves like it already did for sequences and open arrays, so a closure that captured a loop variable of aforloop over an array no longer compiles. Copy the variable first, or pass-d:nimNoLentIterators. std/parsesqlmoved to a Nimble package. Install it throughnimbleoratlas.- Async TLS now verifies the host name.
std/asyncnet, and thereforeAsyncHttpClient, checks that the server certificate matches the host when the context usesCVerifyPeer. A mismatch raisesSslErrorfromAsyncSocket.connect, not from the first read.
Language Changes
Three features are in, but only behind flags. --experimental:typeBoundOps makes hash, $ and == resolve through the type itself even when the defining module is imported with from ... import. --experimental:ownedRefs adds statically checked unique ownership on top of ARC/ORC, so a type whose references are all owned or .cursor stays out of the cycle collector.
Sum types, ported from Nimony, are the third: an object case without a discriminator declares one, branch names construct values, and a matching case binds the branch fields. Fields are reachable only through such a case or inside a {.cast(uncheckedAccess).} section. Seven more Unicode characters are now lexed as operators with the same precedence as *, following the language's existing rule that the compiler only lexes them and user code decides what they mean.
Standard Library
httpclient.newHttpClientacceptsmaxBodySize; a larger response raisesProtocolErrorinstead of buffering without limit.- Header names that are not RFC 9110 tokens are rejected with
ValueErrorrather than sent. osproc.startProcesson Windows raisesOSErrorfor.batand.cmdcommands when an argument contains characterscmd.exewould interpret, closing the command injection path tracked as CVE-2024-24576.system.readRawDataStablereturns a pointer into a string's character data that stays valid across moves and copies, with the same signature under refc, ARC/ORC and--strings:sso.std/filesandstd/dirsgainedPath-based copy, remove and permission operations, includingcopyFileWithPermissionsandcopyDirWithPermissions.std/parseoptgained aCliModeenum withNim,LaxandGnuparsing modes.std/nre2arrives as a replacement for NRE.std/reandstd/nreare deprecated now that PCRE is obsolete.strutils.multiReplacehas an overload for character-set replacement in a single pass, andsetutilsaddssymmetricDifferenceplus its-+-operator.
Tooling
nim doc accepts --raw to emit JSON without markup, --stdinfile names the file used when running a program from standard input, and --styleCheck:warning downgrades style violations from errors. Hot code reloading now works on Linux arm64 with glibc, and a global whose type changed under reload stops the program with a message naming it instead of reading old memory through the new layout.
Upgrade Notes
Run choosenim update 2.4.2 or pull the new package from your distro. Then compile with --styleCheck:warning and --warning:ImplicitRangeConversion enabled before touching default settings, because the two loudest 2.4 changes, bare except: and lent iteration, surface as compile errors rather than runtime surprises. Projects that leaned on std/parsesql or NRE need a dependency line before the build passes.