Version 2.0.0 RC2
31 March 2023 The Nim Team
The second release candidate (RC2) for Nim version 2.0 is ready for testing.
Don’t panic! One of our design goals was to make it easy to write code that works with Nim version 1 and 2.
Many important packages already work with version 2 and as usual many innovations are behind switches
that can be enabled or disabled on a per module level thanks to the .experimental
pragma.
Version 2 is based on the same codebase as version 1, it’s an evolution, not a revolution.
Compared to the RC1, we have many ORC-related bugfixes, but the most crucial difference for ordinary users are the vastly improved error messages:
proc foo(s: string) = discard
proc foo(x, y: int) = discard
proc foo(c: char) = discard
foo 4
produces:
temp3.nim(11, 1) Error: type mismatch
Expression: foo 4
[1] 4: int literal(4)
Expected one of (first mismatch at [position]):
[1] proc foo(c: char)
[1] proc foo(s: string)
[2] proc foo(x, y: int)
For the complete list of new features and bug fixes in Nim 2.0 compared to Nim 1.x, please check our Nim v2.0.0 RC1 article.
Installing Nim 2.0 RC2
Building from source
git clone https://github.com/nim-lang/Nim
cd Nim
git checkout version-2-0
sh build_all.sh
The last command can be re-run after pulling new commits.
Using nightlies build
Download a nightly build.
Bugfixes
These reported issues were fixed, on top of all bugfixes already in RC1:
- Fixed “SIGSEGV possibly caused by literal type” (#16541)
- Fixed “strutils.nim(954, 13) Warning: target type is larger than source type [CastSizes]” (#20244)
- Fixed “Bad C++ codegen on distinct generics C++ types (Atomics here).” (#12946)
- Fixed “{.compileTime.} tuple destructuring - crash on 0.20, bad codegen on 0.19” (#11634)
- Fixed “calling
system.card[T](x: set[T])
withT
ofint8
oruint8
uses mismatched C array sizes” (#20997) - Fixed “Visual Studio(VCC) 2019 cannot compile empty tuple generated by Nim” (#14667)
- Fixed “Fatal memory overwrite bug with
acyclic
pragmas” (#21171) - Fixed “The changelog.md file is missing in the release tarball” (#19997)
- Fixed “line number missing from stacktrace “ (#14444)
- Fixed “panicoverride / patching fatal, doesn’t work for assertions in Nim 2.0 RC1” (#21195)
- Fixed “Incorrect codegen for VCC compiler” (#15117)
- Fixed “Little Copyright notice inconsistency” (#20906)
- Fixed “Keys in enum are case-sensitive on OSX and case-insensitive on linux” (#21207)
- Fixed “Nimsuggest: Importing std/times with the JS backend reports bogus compile error” (#21209)
- Fixed “highlite.getNextToken() returns gtEof if only ‘/’ in C.” (#21232)
- Fixed “
{.requiresInit.}
has several bugs” (#20253) - Fixed “New concepts based on RFCs#168 doesn’t resolve correctly” (#21263)
- Fixed “Compiler crash on recursive object in sum type [regression]” (#21260)
- Fixed “Source download from Nim releases doesn’t have build_all.sh” (#21243)
- Fixed “Overloaded enum with {.pure.} causes nim check to segfault” (#21257)
- Fixed “getImpl for closure iterator works unreliably” (#19818)
- Fixed “std/deques: wrong result after calling shrink” (#21278)
- Fixed “std/xmltree: adds indentation incorrectly to text nodes” (#21290)
- Fixed “
nim doc
is not executing runnableExamples in version 1.9.1 [regression]” (#21261) - Fixed “
io.readLine
adds ‘\00’ char to the end” (#21273) - Fixed “&”{1.236:<.2}” doesn’t work in VM.” (#18134)
- Fixed “Should Nim VM callbacks be a table instead of a sequence?” (#14409)
- Fixed “C++ Atomics: operator= is implicitly deleted because the default definition would be ill-formed” (#13093)
- Fixed “
for ai in a
has quadratic complexity in VM whena
is const” (#16790) - Fixed “New JS mdoe issue: return + ref ints.” (#21317)
- Fixed “nim doc documents unexported fields of exported types” (#19396)
- Fixed “Bad codegen for passed var seq to proc returning array[] converted to seq with @” (#21333)
- Fixed “[vcc] There is no way to set the compiler toolset version “ (#21335)
- Fixed “
Error: internal error: cannot map the empty seq type to a C type
with@[]
” (#21360) - Fixed “dotcall mismatch” (#1072)
- Fixed “iterator declaration zeros variable on ARC/ORC” (#19795)
- Fixed “IntSet mutates inside func” (#21393)
- Fixed “Can not use nim 2’s new default instantiation with any object type with a
distinct DateTime
field” (#20695) - Fixed “SIGSEGV from typed macros” (#17864)
- Fixed “JS backend: Can’t iterate over openArray in proc that’s returned by another proc” (#21439)
- Fixed “enable norm in the important packages” (#21452)
- Fixed “C++ backend: Nim memsetting imported classes to 0 breaks semantics established by default constructor of imported classes” (#21279)
- Fixed “[vm] Set/string/seq inside loop not initialized properly” (#10938)
- Fixed “Orc compiler crash when not making object from
lineInfoObj
into a literal” (#21326) - Fixed “=sink .error is not respected” (#19291)
- Fixed “Mutating a var parameter through a mutable view triggers SIGSEGV” (#20422)
- Fixed “gcc error when constructing an object that has the same name in the same file name in 2 different directories” (#20139)
- Fixed “Move nim-gdb.py and add nim-lldb.py” (#21461)
- Fixed “small issue in documentation with osproc.waitForExit” (#21449)
- Fixed “[Codegen] function call is not emitted” (#21272)
- Fixed “return type inference broken for generic closures” (#16654)
- Fixed “Invalid C code can be generated when using std/sugar arrow syntax without specifying types” (#20704)
- Fixed “ICE returning
@[]
asseq[int]
” (#21377) - Fixed “Incorrect number of types needed to call a proc with an argument being a sum of generics” (#6231)
- Fixed “Compiler hangs when using generics” (#8295)
- Fixed “Segfault when mixing seqs, orc, variants and futures” (#21023)
- Fixed “Segfault compiling async-related code” (#21306)
- Fixed “Ambiguous calls compiles when module name are equal” (#21496)
- Fixed “Exception raised in closure may be “skipped” (
--exceptions:goto
)” (#19857) - Fixed “Change branch of an object variant is allowed” (#18977)
- Fixed “Inconsistent behavior with certain procs when XML node kind is xnVerbatimText” (#21541)
- Fixed “newSeqWith: Unexpected behavior when len template parameter contains side effects” (#21538)
- Fixed “Generics for tuple” (#21536)
- Fixed “[Codegen] function call is not emitted” (#21272)
- Fixed “Private field is not resolved properly in templates” (#3770)
- Fixed “Crash in compiler when using system.any by accident.” (#14255)
- Fixed “importcpp types with explicit constructor “producing chosen constructor is explicit in copy-initialization”” (#21505)
- Fixed “[ARC] Destructor falsely injected in code with generics & a type alias” (#20993)