Skip to main content

Nim 2.4.2

Release Date: November 12, 2026

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:solaris and --os:illumos both define sunos, posix and unix, but illumos no longer defines solaris. Code shared by both should test defined(sunos).
  • --compileOnly no 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 --mergeableCcode switch.
  • Float round-trip formatting is the default. -d:nimPreviewFloatRoundtrip moved out of preview: system.addFloat and system.$ now produce minimal, correctly rounded representations using the Dragonbox algorithm. -d:nimLegacySprintf emulates the old output.
  • tables.getOrDefault renamed its parameter from default to def, because the old name collided with system.default. Call sites using default = ... by name must be edited.
  • Bare except: panics on Defect. Use except Exception: or except Defect:. --legacy:noPanicOnExcept exists as a transition flag.
  • Array iteration yields lent T. items for arrays now behaves like it already did for sequences and open arrays, so a closure that captured a loop variable of a for loop over an array no longer compiles. Copy the variable first, or pass -d:nimNoLentIterators.
  • std/parsesql moved to a Nimble package. Install it through nimble or atlas.
  • Async TLS now verifies the host name. std/asyncnet, and therefore AsyncHttpClient, checks that the server certificate matches the host when the context uses CVerifyPeer. A mismatch raises SslError from AsyncSocket.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.newHttpClient accepts maxBodySize; a larger response raises ProtocolError instead of buffering without limit.
  • Header names that are not RFC 9110 tokens are rejected with ValueError rather than sent.
  • osproc.startProcess on Windows raises OSError for .bat and .cmd commands when an argument contains characters cmd.exe would interpret, closing the command injection path tracked as CVE-2024-24576.
  • system.readRawDataStable returns 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/files and std/dirs gained Path-based copy, remove and permission operations, including copyFileWithPermissions and copyDirWithPermissions.
  • std/parseopt gained a CliMode enum with Nim, Lax and Gnu parsing modes.
  • std/nre2 arrives as a replacement for NRE. std/re and std/nre are deprecated now that PCRE is obsolete.
  • strutils.multiReplace has an overload for character-set replacement in a single pass, and setutils adds symmetricDifference plus 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.

Other Versions

We use cookies for ads and analytics.