0.20.2现已发布

Nim团队很荣幸为大家带来0.20.2版本,这是我们为1.0版本准备的第二个RC版本。

请点击之前的版本发布日志 以查看更多关于0.20版本的信息,以及我们关于1.0及之后版本的计划。 此版本主要包含了对0.20.0(1.0 RC1)版本的BUG修复。

唯一的新功能是我们添加了名为toOpenArray的切片操作符, 现对JavaScript后端可用。

这次更新距离上一个版本的发布尽管只差了一个月, 但它却包含了超过200次的新commit,修复了超过70个被提出来的issues, 并且带来了很多应该能让Nim更加稳定的改进。

代码风格检查

在0.20.0版本发布后,我们改进了我们的代码样式检查器, 现在可以通过在启动Nim时加上--styleCheck:error标识, 这意味着可以对编译器和标准库进行代码风格检查了, 如果使用了不同的代码风格(比如:fooBarfoo_bar),那么这些代码将不会被编译。

Nimpretty

我们对于这个版本的关注点还有一个,那就是我们的nimpretty工具: 这是一个Nim的源码美化器, 用来把代码格式化得符合官方风格(NEP-1)。 我们进行了超过30个提交,以改善nimpretty体验,让它更有能力应对现实场景。

新的runtime

新的runtime进展很顺利,但它还没有达到预想的状态, 所以他在1.0版本中将作为一个可选的特性。 下一个重要的里程碑是使新的运行时与async一起工作。 只有完成这一点,我们才会真正地进行推广,让大家优先考虑它。

安装0.20.2版本

你之前如果已经使用choosenim来安装了旧版本的Nim, 那么更新到0.20.2版本将会非常的简单:

$ choosenim update stable

如果你之前并没有使用它,你可以通过 这篇介绍来获取choosenim。 当然你也可以直接根据我们的安装页面, 单独安装Nim。

(译者注:在Windows下的choosenim只支持32位的下载, 你可以在64位系统下进行安装,但是这样的话你的nim版本只能也使用32位的,否则会报错)

不向后兼容的更新

  • All strutils.rfind procs now take start and last like strutils.find with the same data slice/index meaning. This is backwards compatible for calls not changing the rfind start parameter from its default. (#11487)

    In the unlikely case that you were using rfind X, start=N, or rfind X, N, then you need to change that to rfind X, last=N or rfind X, 0, N. (This should minimize gotchas porting code from other languages like Python or C++.)

  • On Windows stderr/stdout/stdin are not opened as binary files anymore. Use the switch -d:nimBinaryStdFiles for a transition period.

影响标准库的更新

  • Mac OS X / BSD: TSa_Family is now the uint8 type, so type conversions like x.sin_family = uint16 toInt(nativesockets.AF_INET) need to be changed into x.sin_family = TSa_Family toInt(nativesockets.AF_INET).

库的新增

  • 用于JS的toOpenArray 现已可用。

库的更新

  • Fix async IO operations stalling even after socket is closed. (#11232)

  • More informative error message for streams.openFileStream. (#11438)

编译器更新

  • Better error message for IndexError for empty containers. (#11476)

  • Fix regression in semfold for old right shift. (#11477)

  • Fix for passing tuples as static params to macros. (#11423)

Bug修复

  • Fixed “nimpretty goes crazy with this snippet” (#10295)
  • Fixed “nimpretty doesn’t trim all whitespace on the right side of an export marker” (#10177)
  • Fixed “nimpretty gives invalid indentation to array elements” (#9505)
  • Fixed “nimpretty doesn’t indent correctly if preceding line ends with ;, { etc” (#10159)
  • Fixed “Nimpretty wrong indentation for doc comments” (#10156)
  • Fixed “HttpClient Documentation needs Proxy example” (#11281)
  • Fixed “nimpretty aligns comment annoyingly” (#9399)
  • Fixed “ENDB missing from Docs and TheIndex, remove ENDB from –fullhelp” (#11431)
  • Fixed “Nimrod on Documentation generator” (#11460)
  • Fixed “nimpretty (de)indents code where it shouldn’t” (#11468)
  • Fixed “nimpretty adds spaces where it shouldn’t” (#11470)
  • Fixed “nimpretty formats enums differently based on commas” (#11467)
  • Fixed “strutils.rfind start parameter is unecessarily unusual” (#11430)
  • Fixed “TinyC is not documented” (#11495)
  • Fixed “c2nim missing from 0.20.0” (#11434)
  • Fixed “nimsuggest doesn’t work unless compiled with -d:danger” (#11482)
  • Fixed “random.initRand crashes in Nim 0.20.0 JS backend” (#11450)
  • Fixed “0.20.0 fails to bootstrap when passing “–verbosity:2” (or 3) to koch” (#11436)
  • Fixed “Destructors lifting doesn’t work with inheritance” (#11517)
  • Fixed “std/sums missing from TheIndex” (#11543)
  • Fixed “sequtils module: link is broken” (#11546)
  • Fixed “Case Statement Macros do not work in functions above exported functions.” (#11556)
  • Fixed “newruntime: internal error when initializing a proc variable” (#11533)
  • Fixed “newruntime: error when modifying a sequence” (#11524)
  • Fixed “fmod and other math module functions are missing in js mode” (#4630)
  • Fixed “Object variants and new runtime” (#11563)
  • Fixed “newruntime exceptions” (#11577)
  • Fixed “nimpretty is not aware that the next line is a part of the same context” (#11469)
  • Fixed “Distinct procs fail to compile” (#11600)
  • Fixed “[SharedTables] Error: undeclared identifier: ‘defaultInitialSize’” (#11588)
  • Fixed “newSeqOfCap is not working in newruntime” (#11098)
  • Fixed “nimpretty destroys source with a source code filter” (#11532)
  • Fixed “Unexpected behaviour when constructing with result” (#11525)
  • Fixed “Regression in 0.20.0: Nested proc using outer scope variable fails to compile” (#11523)
  • Fixed “os:standalone Error: redefinition of ‘nimToCStringConv’ “ (#11445)
  • Fixed “No ambiguity error on field overloaded by field=” (#11514)
  • Fixed “object variants and new runtime part 2” (#11611)
  • Fixed “seq Error: unhandled exception: value out of range: 32772 “ (#11606)
  • Fixed “Compiled binary includes full path to internal nim files” (#11572)
  • Fixed “Newruntime: top-level string variable is empty after an array assignment” (#11614)
  • Fixed “Newruntime: raise ObjContructor() doesn’t compile” (#11628)
  • Fixed “Owned ref can be copied and causes double-free” (#11617)
  • Fixed “When compiling to JS (in -d:release) output contains toolchain path on dev’s machine” (#11545)
  • Fixed “wrong unicode string output” (#11618)
  • Fixed “unittest “generic instantiation too nested” error” (#11515)
  • Fixed “Last read of a var parameter generates sink instead of assignment” (#11633)
  • Fixed “const table with proc type does not compile anymore” (#11479)
  • Fixed “Can’t use offsetOf on object that ends with an UncheckedArray” (#11320)
  • Fixed “Newruntime/regression: Bad codegen for inline methods” (#11636)
  • Fixed “String or sequences inside a loop are not cleared in each iteration” (#11510)
  • Fixed “Nim -v doesn’t acknowledge new danger flag” (#11484)
  • Fixed “SIGSEGV while compiling when trying to instantiate a case type, that uses an enum with non-zero start” (#11585)
  • Fixed “Compile-time usage of parts of strutils fails when using -d:useNimRtl” (#8405)
  • Fixed “regression(0.20): finally block executed twice in VM” (#11610)
  • Fixed “exportc symbol not exported, leading to link error” (#11651)
  • Fixed “Render bug: opearator priority can be wrong for second argument” (#11662)
  • Fixed “Nim & C disagree on type size” (#6860)
  • Fixed “Spawn passes refs across threads” (#7057)
  • Fixed “BUG: “varargs[string, $]” calls $ n^2 times instead of n times (n=len(varargs))” (#8316)
  • Fixed “Problem with the same name for module and exported type” (#3333)
  • Fixed “–gc:go does not work anymore” (#11447)
  • Fixed “Error: inconsistent typing for reintroduced symbol” (#11494)
  • Fixed “Auto generated destructors for tuples/objects fail with “non-trivial” error…” (#11671)
  • Fixed “Regression: parameter default value + typedesc parameter causes compiler crash” (#11660)
  • Fixed “newruntime: undetected dangling ref” (#11350)
  • Fixed “Newruntime: setLen() not working on sequences of owned refs” (#11530)
  • Fixed “Incorrect overflow/underflow error in case statements” (#11551)
  • Fixed “cgen preprocessor directive placed after struct declaration” (#11691)
  • Fixed “continue in an except Exception as e block crashes the compiler.” (#11683)
  • Fixed “nimsuggest, nim check segfault when using bindSym and doAssert” (#10901)
  • Fixed “Nimpretty issue, multiline string of x length only causes output grow every time.” (#11700)
  • Fixed “Array indexed by distinct int doesnt work with iterators” (#11715)