-
httpclient.contentLength
default to-1
if the Content-Length header is not set in the response, it followed Apache HttpClient(Java), http(go) and .Net HttpWebResponse(C#) behavior. Previously it raisedValueError
. -
addr
is now available for all addressable locations,unsafeAddr
is now deprecated and an alias foraddr
. -
Certain definitions from the default
system
module have been moved to the following new modules:std/syncio
std/assertions
std/formatfloat
std/objectdollar
std/widestrs
std/threads
In the future, these definitions will be removed from the
system
module, and their respective modules will have to be imported to use them. Currently, to make these imports required, the-d:nimPreviewSlimSystem
option may be used. -
Enabling
-d:nimPreviewSlimSystem
also removes the following deprecated symbols in thesystem
module:- Aliases with
Error
suffix to exception types that have aDefect
suffix (see exceptions):ArithmeticError
,DivByZeroError
,OverflowError
,AccessViolationError
,AssertionError
,OutOfMemError
,IndexError
,FieldError
,RangeError
,StackOverflowError
,ReraiseError
,ObjectAssignmentError
,ObjectConversionError
,FloatingPointError
,FloatOverflowError
,FloatUnderflowError
,FloatInexactError
,DeadThreadError
,NilAccessError
addQuitProc
, replaced byexitprocs.addExitProc
- Legacy unsigned conversion operations:
ze
,ze64
,toU8
,toU16
,toU32
TaintedString
, formerly a distinct alias tostring
PInt32
,PInt64
,PFloat32
,PFloat64
, aliases toptr int32
,ptr int64
,ptr float32
,ptr float64
- Aliases with
-
Enabling
-d:nimPreviewSlimSystem
removes the import ofchannels_builtin
in in thesystem
module. -
The
gc:v2
option is removed. -
The
mainmodule
andm
options are removed. -
The
threads:on
option is now the default. -
Optional parameters in combination with
: body
syntax (RFC #405) are now opt-in viaexperimental:flexibleOptionalParams
. -
Automatic dereferencing (experimental feature) is removed.
-
The
Math.trunc
polyfill for targeting Internet Explorer was previously included in most JavaScript output files. Now, it is only included with-d:nimJsMathTruncPolyfill
. If you are targeting Internet Explorer, you may choose to enable this option or define your ownMath.trunc
polyfill using theemit
pragma. Nim usesMath.trunc
for the division and modulo operators for integers. -
shallowCopy
andshallow
are removed for ARC/ORC. Usemove
when possible or combine assignment andsink
for optimization purposes. -
The
nimPreviewDotLikeOps
define is going to be removed or deprecated. -
The
{.this.}
pragma, deprecated since 0.19, has been removed. -
nil
literals can no longer be directly assigned to variables or fields ofdistinct
pointer types. They must be converted instead.type Foo = distinct ptr int # Before: var x: Foo = nil # After: var x: Foo = Foo(nil)
-
Removed two type pragma syntaxes deprecated since 0.20, namely
type Foo = object {.final.}
, andtype Foo {.final.} [T] = object
. -
Overloadable enums and Unicode Operators are no longer experimental.
-
Removed the
nimIncrSeqV3
define. -
macros.getImpl
forconst
symbols now returns the full definition node (asnnkConstDef
) rather than the AST of the constant value. -
Lock levels are deprecated, now a noop.
-
ORC is now the default memory management strategy. Use
--mm:refc
for a transition period. -
strictEffects
are no longer experimental. Uselegacy:laxEffects
to keep backward compatibility. -
The
gorge
/staticExec
calls will now return a descriptive message in the output if the execution fails for whatever reason. To get back legacy behaviour use-d:nimLegacyGorgeErrors
.
-
OpenSSL 3 is now supported.
-
macros.parseExpr
andmacros.parseStmt
now accept an optional filename argument for more informative errors. -
Module
colors
expanded with missing colors from the CSS color standard.colPaleVioletRed
andcolMediumPurple
have also been changed to match the CSS color standard. -
Fixed
lists.SinglyLinkedList
being broken after removing the last node (#19353). -
The
md5
module now works at compile time and in JavaScript. -
std/smtp
sendsehlo
first. If the mail server does not understand, it sendshelo
as a fallback. -
Changed
mimedb
to use anOrderedTable
instead ofOrderedTableRef
to supportconst
tables. -
strutils.find
now uses and defaults tolast = -1
for whole string searches, making limiting it to just the first char (last = 0
) valid. -
random.rand
now works withOrdinal
s. -
Undeprecated
os.isvalidfilename
. -
std/oids
now usesint64
to store time internally (before it was int32). -
std/uri.Uri
dollar$
improved, precalculates thestring
result length from theUri
. -
std/uri.Uri.isIpv6
is now exported. -
std/net.IpAddress
dollar$
improved, uses a fixed capacity for thestring
result based from theIpAddressFamily
. -
std/jsfetch.newFetchOptions
now has default values for all parameters
- Added ISO 8601 week date utilities in
times
:- Added
IsoWeekRange
, a range type for weeks in a week-based year. - Added
IsoYear
, a distinct type for a week-based year in contrast to a regular year. - Added a
initDateTime
overload to create a datetime from an ISO week date. - Added
getIsoWeekAndYear
to get an ISO week number and week-based year from a datetime. - Added
getIsoWeeksInYear
to return the number of weeks in a week-based year.
- Added
- Added new modules which were part of
std/os
:- Added
std/oserrors
for OS error reporting. Addedstd/envvars
for environment variables handling. - Added
std/paths
,std/dirs
,std/files
,std/symlinks
andstd/appdirs
.
- Added
- Added
sep
parameter instd/uri
to specify the query separator. - Added bindings to
Array.shift
andqueueMicrotask
injscore
for JavaScript targets. - Added
UppercaseLetters
,LowercaseLetters
,PunctuationChars
,PrintableChars
sets tostd/strutils
. - Added
complex.sgn
for obtaining the phase of complex numbers. - Added
insertAdjacentText
,insertAdjacentElement
,insertAdjacentHTML
,after
,before
,closest
,append
,hasAttributeNS
,removeAttributeNS
,hasPointerCapture
,releasePointerCapture
,requestPointerLock
,replaceChildren
,replaceWith
,scrollIntoViewIfNeeded
,setHTML
,toggleAttribute
, andmatches
tostd/dom
. - Added
jsre.hasIndices
- Added
capacity
forstring
andseq
to return the current capacity, see nim-lang/RFCs#460 - Added
openArray[char]
overloads forstd/parseutils
allowing more code reuse. - Added
openArray[char]
overloads forstd/unicode
allowing more code reuse. - Added
safe
parameter tobase64.encodeMime
.
- Deprecated
selfExe
for Nimscript. - Deprecated
std/sums
. - Deprecated
std/base64.encode
for collections of arbitrary integer element type. Now onlybyte
andchar
are supported.
- Removed deprecated module
parseopt2
. - Removed deprecated module
sharedstrings
. - Removed deprecated module
dom_extensions
. - Removed deprecated module
LockFreeHash
. - Removed deprecated module
events
. - Removed deprecated
oids.oidToString
. - Removed define
nimExperimentalAsyncjsThen
forstd/asyncjs.then
andstd/jsfetch
. - Removed deprecated
jsre.test
andjsre.toString
. - Removed deprecated
math.c_frexp
. - Removed deprecated
httpcore.`==`
. - Removed deprecated
std/posix.CMSG_SPACE
andstd/posix.CMSG_LEN
that takes wrong argument types. - Removed deprecated
osproc.poDemon
, symbol with typo.
-
Tag tracking supports the definition of forbidden tags by the
.forbids
pragma which can be used to disable certain effects in proc types. -
Case statement macros are no longer experimental, meaning you no longer need to enable the experimental switch
caseStmtMacros
to use them. -
Full command syntax and block arguments i.e.
foo a, b: c
are now allowed for the right-hand side of type definitions in type sections. Previously they would error with "invalid indentation". -
defined
now accepts identifiers separated by dots, i.e.defined(a.b.c)
. In the command line, this is defined as-d:a.b.c
. Older versions can use accents as indefined(`a.b.c`)
to access such defines. -
Macro pragmas changes:
-
Templates now accept macro pragmas.
-
Macro pragmas for var/let/const sections have been redesigned in a way that works similarly to routine macro pragmas. The new behavior is documented in the experimental manual.
-
Pragma macros on type definitions can now return
nnkTypeSection
nodes as well asnnkTypeDef
, allowing multiple type definitions to be injected in place of the original type definition.import macros macro multiply(amount: static int, s: untyped): untyped = let name = $s[0].basename result = newNimNode(nnkTypeSection) for i in 1 .. amount: result.add(newTree(nnkTypeDef, ident(name & $i), s[1], s[2])) type Foo = object Bar {.multiply: 3.} = object x, y, z: int Baz = object # becomes type Foo = object Bar1 = object x, y, z: int Bar2 = object x, y, z: int Bar3 = object x, y, z: int Baz = object
-
-
Redefining templates with the same signature implicitly was previously allowed to support certain macro code. A
{.redefine.}
pragma has been added to make this work explicitly, and a warning is generated in the case where it is implicit. This behavior only applies to templates, redefinition is generally disallowed for other symbols. -
A new form of type inference called top-down inference has been implemented for a variety of basic cases. For example, code like the following now compiles:
let foo: seq[(float, byte, cstring)] = @[(1, 2, "abc")]
-
cstring
is now accepted as a selector incase
statements, removing the need to convert tostring
. On the JS backend, this is translated directly to aswitch
statement. -
Nim now supports
out
parameters and "strict definitions". -
Nim now offers a strict mode for
case objects
.
-
The
gc
switch has been renamed tomm
("memory management") in order to reflect the reality better. (Nim moved away from all techniques based on "tracing".) -
Defines the
gcRefc
symbol which allows writing specific code for the refc GC. -
nim
can now compile version 1.4.0 as follows:nim c --lib:lib --stylecheck:off compiler/nim
, without requiring-d:nimVersion140
which is now a noop. -
--styleCheck
,--hintAsError
and--warningAsError
now only apply to the current package. -
The switch
--nimMainPrefix:prefix
has been added to add a prefix to the names ofNimMain
and related functions produced on the backend. This prevents conflicts with other Nim static libraries. -
When compiling for Release the flag
-fno-math-errno
is used for GCC.
- Nim now supports Nimble version 0.14 which added support for lock-files. This is done by
a simple configuration change setting that you can do yourself too. In
$nim/config/nim.cfg
replacepkgs
bypkgs2
.