diff options
Diffstat (limited to 'changelogs')
-rw-r--r-- | changelogs/changelog_0_19_0.md | 2 | ||||
-rw-r--r-- | changelogs/changelog_1_4_0.md | 874 | ||||
-rw-r--r-- | changelogs/changelog_1_6_0.md | 957 | ||||
-rw-r--r-- | changelogs/changelog_2_0_0.md | 330 | ||||
-rw-r--r-- | changelogs/changelog_2_0_0_details.md | 560 | ||||
-rw-r--r-- | changelogs/changelog_2_2_0.md | 248 | ||||
-rw-r--r-- | changelogs/changelog_X_XX_X.md | 7 |
7 files changed, 2975 insertions, 3 deletions
diff --git a/changelogs/changelog_0_19_0.md b/changelogs/changelog_0_19_0.md index 18d3ca2b3..45cefe933 100644 --- a/changelogs/changelog_0_19_0.md +++ b/changelogs/changelog_0_19_0.md @@ -15,7 +15,7 @@ at runtime. Use ``ref object`` with inheritance rather than ``object`` with inheritance to prevent this issue. - The ``not nil`` type annotation now has to be enabled explicitly - via ``{.experimental: "notnil"}`` as we are still not pleased with how this + via ``{.experimental: "notnil".}`` as we are still not pleased with how this feature works with Nim's containers. - The parser now warns about inconsistent spacing around binary operators as these can easily be confused with unary operators. This warning will likely diff --git a/changelogs/changelog_1_4_0.md b/changelogs/changelog_1_4_0.md new file mode 100644 index 000000000..77f66ffde --- /dev/null +++ b/changelogs/changelog_1_4_0.md @@ -0,0 +1,874 @@ +# v1.4.0 - 2020-10-16 + + + +## Standard library additions and changes + +- Added some enhancements to `std/jsonutils` module. + * Added a possibility to deserialize JSON arrays directly to `HashSet` and + `OrderedSet` types and respectively to serialize those types to JSON arrays + via `jsonutils.fromJson` and `jsonutils.toJson` procedures. + * Added a possibility to deserialize JSON `null` objects to Nim option objects + and respectively to serialize Nim option object to JSON object if `isSome` + or to JSON null object if `isNone` via `jsonutils.fromJson` and + `jsonutils.toJson` procedures. + * Added a `Joptions` parameter to `jsonutils.fromJson` currently + containing two boolean options `allowExtraKeys` and `allowMissingKeys`. + - If `allowExtraKeys` is `true` Nim's object to which the JSON is parsed is + not required to have a field for every JSON key. + - If `allowMissingKeys` is `true` Nim's object to which JSON is parsed is + allowed to have fields without corresponding JSON keys. +- Added `bindParams`, `bindParam` to `db_sqlite` for binding parameters into a `SqlPrepared` statement. +- Added `tryInsert`,`insert` procs to `db_*` libs which accept primary key column name. +- Added `xmltree.newVerbatimText` support create `style`'s,`script`'s text. +- `uri` module now implements RFC-2397. +- Added [DOM Parser](https://developer.mozilla.org/en-US/docs/Web/API/DOMParser) + to the `dom` module for the JavaScript target. +- The default hash for `Ordinal` has changed to something more bit-scrambling. + `import hashes; proc hash(x: myInt): Hash = hashIdentity(x)` recovers the old + one in an instantiation context while `-d:nimIntHash1` recovers it globally. +- `deques.peekFirst` and `deques.peekLast` now have `var Deque[T] -> var T` overloads. +- File handles created from high-level abstractions in the stdlib will no longer + be inherited by child processes. In particular, these modules are affected: + `asyncdispatch`, `asyncnet`, `system`, `nativesockets`, `net` and `selectors`. + + For `asyncdispatch`, `asyncnet`, `net` and `nativesockets`, an `inheritable` + flag has been added to all `proc`s that create sockets, allowing the user to + control whether the resulting socket is inheritable. This flag is provided to + ease the writing of multi-process servers, where sockets inheritance is + desired. + + For a transition period, define `nimInheritHandles` to enable file handle + inheritance by default. This flag does **not** affect the `selectors` module + due to the differing semantics between operating systems. + + `asyncdispatch.setInheritable`, `system.setInheritable` and + `nativesockets.setInheritable` are also introduced for setting file handle or + socket inheritance. Not all platforms have these `proc`s defined. + +- The file descriptors created for internal bookkeeping by `ioselector_kqueue` + and `ioselector_epoll` will no longer be leaked to child processes. + +- `strutils.formatFloat` with `precision = 0` has been restored to the version + 1 behaviour that produces a trailing dot, e.g. `formatFloat(3.14159, precision = 0)` + is now `3.`, not `3`. +- Added `commonPrefixLen` to `critbits`. + +- `relativePath(rel, abs)` and `relativePath(abs, rel)` used to silently give wrong results + (see #13222); instead they now use `getCurrentDir` to resolve those cases, + and this can now throw in edge cases where `getCurrentDir` throws. + `relativePath` also now works for js with `-d:nodejs`. + +- JavaScript and NimScript standard library changes: `streams.StringStream` is + now supported in JavaScript, with the limitation that any buffer `pointer`s + used must be castable to `ptr string`, any incompatible pointer type will not + work. The `lexbase` and `streams` modules used to fail to compile on + NimScript due to a bug, but this has been fixed. + + The following modules now compile on both JS and NimScript: `parsecsv`, + `parsecfg`, `parsesql`, `xmlparser`, `htmlparser` and `ropes`. Additionally + supported for JS is `cstrutils.startsWith` and `cstrutils.endsWith`, for + NimScript: `json`, `parsejson`, `strtabs` and `unidecode`. + +- Added `streams.readStr` and `streams.peekStr` overloads to + accept an existing string to modify, which avoids memory + allocations, similar to `streams.readLine` (#13857). + +- Added high-level `asyncnet.sendTo` and `asyncnet.recvFrom` UDP functionality. + +- `dollars.$` now works for unsigned ints with `nim js`. + +- Improvements to the `bitops` module, including bitslices, non-mutating versions + of the original masking functions, `mask`/`masked`, and varargs support for + `bitand`, `bitor`, and `bitxor`. + +- `sugar.=>` and `sugar.->` changes: Previously `(x, y: int)` was transformed + into `(x: auto, y: int)`, it now becomes `(x: int, y: int)` for consistency + with regular proc definitions (although you cannot use semicolons). + + Pragmas and using a name are now allowed on the lefthand side of `=>`. Here + is an example of these changes: + ```nim + import sugar + + foo(x, y: int) {.noSideEffect.} => x + y + + # is transformed into + + proc foo(x: int, y: int): auto {.noSideEffect.} = x + y + ``` + +- The fields of `times.DateTime` are now private, and are accessed with getters and deprecated setters. + +- The `times` module now handles the default value for `DateTime` more consistently. + Most procs raise an assertion error when given + an uninitialized `DateTime`, the exceptions are `==` and `$` (which returns `"Uninitialized DateTime"`). + The proc `times.isInitialized` has been added which can be used to check if + a `DateTime` has been initialized. + +- Fix a bug where calling `close` on io streams in `osproc.startProcess` was a noop and led to + hangs if a process had both reads from stdin and writes (e.g. to stdout). + +- The callback that is passed to `system.onThreadDestruction` must now be `.raises: []`. +- The callback that is assigned to `system.onUnhandledException` must now be `.gcsafe`. + +- `osproc.execCmdEx` now takes an optional `input` for stdin, `workingDir` and `env` + parameters. + +- Added a `ssl_config` module containing lists of secure ciphers as recommended by + [Mozilla OpSec](https://wiki.mozilla.org/Security/Server_Side_TLS) + +- `net.newContext` now defaults to the list of ciphers targeting + ["Intermediate compatibility"](https://wiki.mozilla.org/Security/Server_Side_TLS#Intermediate_compatibility_.28recommended.29) + per Mozilla's recommendation instead of `ALL`. This change should protect + users from the use of weak and insecure ciphers while still provides + adequate compatibility with the majority of the Internet. + +- A new module `std/jsonutils` with hookable `jsonTo,toJson,fromJson` operations for json + serialization/deserialization of custom types was added. + +- A new proc `heapqueue.find[T](heap: HeapQueue[T], x: T): int` to get index of element ``x`` + was added. +- Added `rstgen.rstToLatex` a convenience proc for `renderRstToOut` and `initRstGenerator`. +- Added `os.normalizeExe`. +- `macros.newLit` now preserves named vs unnamed tuples. +- Added `random.gauss`, that uses the ratio of uniforms method of sampling from a Gaussian distribution. +- Added `typetraits.elementType` to get the element type of an iterable. +- `typetraits.$` changes: `$(int,)` is now `"(int,)"` instead of `"(int)"`; + `$tuple[]` is now `"tuple[]"` instead of `"tuple"`; + `$((int, float), int)` is now `"((int, float), int)"` instead of `"(tuple of (int, float), int)"` +- Added `macros.extractDocCommentsAndRunnables` helper. + +- `strformat.fmt` and `strformat.&` support `specifier =`. `fmt"{expr=}"` now + expands to `fmt"expr={expr}"`. +- Deprecations: instead of `os.existsDir` use `dirExists`, instead of `os.existsFile` use `fileExists`. + +- Added the `jsre` module, [Regular Expressions for the JavaScript target.](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions). +- Made `maxLines` argument `Positive` in `logging.newRollingFileLogger`, + because negative values will result in a new file being created for each logged + line which doesn't make sense. +- Changed `log` in `logging` to use proper log level for JavaScript, + e.g. `debug` uses `console.debug`, `info` uses `console.info`, `warn` uses `console.warn`, etc. +- Tables, HashSets, SharedTables and deques don't require anymore that the passed + initial size must be a power of two - this is done internally. + Proc `rightSize` for Tables and HashSets is deprecated, as it is not needed anymore. + `CountTable.inc` takes `val: int` again not `val: Positive`; i.e. it can "count down" again. +- Removed deprecated symbols from `macros` module, some of which were deprecated already in `0.15`. +- Removed `sugar.distinctBase`, deprecated since `0.19`. Use `typetraits.distinctBase`. +- `asyncdispatch.PDispatcher.handles` is exported so that an external low-level libraries can access it. + +- `std/with`, `sugar.dup` now support object field assignment expressions: + ```nim + import std/with + + type Foo = object + x, y: int + + var foo = Foo() + with foo: + x = 10 + y = 20 + + echo foo + ``` + +- Proc `math.round` is no longer deprecated. The advice to use `strformat` instead + cannot be applied to every use case. The limitations and the (lack of) reliability + of `round` are well documented. + +- Added `getprotobyname` to `winlean`. Added `getProtoByname` to `nativesockets` which returns a protocol code + from the database that matches the protocol `name`. + +- Added missing attributes and methods to `dom.Navigator` like `deviceMemory`, `onLine`, `vibrate()`, etc. + +- Added `strutils.indentation` and `strutils.dedent` which enable indented string literals: + ```nim + import strutils + echo dedent """ + This + is + cool! + """ + ``` + +- Added `initUri(isIpv6: bool)` to `uri` module, now `uri` supports parsing ipv6 hostname. + +- Added `readLines(p: Process)` to `osproc`. + +- Added the below `toX` procs for collections. The usage is similar to procs such as + `sets.toHashSet` and `tables.toTable`. Previously, it was necessary to create the + respective empty collection and add items manually. + * `critbits.toCritBitTree`, which creates a `CritBitTree` from an `openArray` of + items or an `openArray` of pairs. + * `deques.toDeque`, which creates a `Deque` from an `openArray`. + * `heapqueue.toHeapQueue`, which creates a `HeapQueue` from an `openArray`. + * `intsets.toIntSet`, which creates an `IntSet` from an `openArray`. + +- Added `progressInterval` argument to `asyncftpclient.newAsyncFtpClient` to control the interval + at which progress callbacks are called. + +- Added `os.copyFileToDir`. + +## Language changes + +- The `=destroy` hook no longer has to reset its target, as the compiler now automatically inserts + `wasMoved` calls where needed. +- The `=` hook is now called `=copy` for clarity. The old name `=` is still available so there + is no need to update your code. This change was backported to 1.2 too so you can use the + more readable `=copy` without loss of compatibility. + +- In the newruntime it is now allowed to assign to the discriminator field + without restrictions as long as the case object doesn't have a custom destructor. + The discriminator value doesn't have to be a constant either. If you have a + custom destructor for a case object and you do want to freely assign discriminator + fields, it is recommended to refactor the object into 2 objects like this: + + ```nim + type + MyObj = object + case kind: bool + of true: y: ptr UncheckedArray[float] + of false: z: seq[int] + + proc `=destroy`(x: MyObj) = + if x.kind and x.y != nil: + deallocShared(x.y) + ``` + Refactor into: + ```nim + type + MySubObj = object + val: ptr UncheckedArray[float] + MyObj = object + case kind: bool + of true: y: MySubObj + of false: z: seq[int] + + proc `=destroy`(x: MySubObj) = + if x.val != nil: + deallocShared(x.val) + ``` +- `getImpl` on enum type symbols now returns field syms instead of idents. This helps + with writing typed macros. The old behavior for backwards compatibility can be restored + with `--useVersion:1.0`. +- The typed AST for proc headers will now have the arguments be syms instead of idents. + This helps with writing typed macros. The old behaviour for backwards compatibility can + be restored with `--useVersion:1.0`. +- ``let`` statements can now be used without a value if declared with + ``importc``/``importcpp``/``importjs``/``importobjc``. +- The keyword `from` is now usable as an operator. +- Exceptions inheriting from `system.Defect` are no longer tracked with + the `.raises: []` exception tracking mechanism. This is more consistent with the + built-in operations. The following always used to compile (and still does): + ```nim + proc mydiv(a, b): int {.raises: [].} = + a div b # can raise an DivByZeroDefect + ``` + + Now also this compiles: + ```nim + proc mydiv(a, b): int {.raises: [].} = + if b == 0: raise newException(DivByZeroDefect, "division by zero") + else: result = a div b + ``` + + The reason for this is that `DivByZeroDefect` inherits from `Defect` and + with `--panics:on` `Defects` become unrecoverable errors. + +- Added the `thiscall` calling convention as specified by Microsoft, mostly for hooking purposes. +- Deprecated the `{.unroll.}` pragma, because it was always ignored by the compiler anyway. +- Removed the deprecated `strutils.isNilOrWhitespace`. +- Removed the deprecated `sharedtables.initSharedTable`. +- Removed the deprecated `asyncdispatch.newAsyncNativeSocket`. +- Removed the deprecated `dom.releaseEvents` and `dom.captureEvents`. + +- Removed `sharedlist.initSharedList`, was deprecated and produces undefined behaviour. + +- There is a new experimental feature called "strictFuncs" which makes the definition of + `.noSideEffect` stricter. [See here](manual_experimental.html#stricts-funcs) + for more information. + +- "for-loop macros" (see [the manual](manual.html#macros-for-loop-macros)) are no longer + an experimental feature. In other words, you don't have to write pragma + `{.experimental: "forLoopMacros".}` if you want to use them. + +- Added the ``.noalias`` pragma. It is mapped to C's ``restrict`` keyword for the increased + performance this keyword can enable. + +- `items` no longer compiles with enums with holes as its behavior was error prone, see #14004. +- `system.deepcopy` has to be enabled explicitly for `--gc:arc` and `--gc:orc` via + `--deepcopy:on`. + +- Added the `std/effecttraits` module for introspection of the inferred effects. + We hope this enables `async` macros that are precise about the possible exceptions that + can be raised. +- The pragma blocks `{.gcsafe.}: ...` and `{.noSideEffect.}: ...` can now also be + written as `{.cast(gcsafe).}: ...` and `{.cast(noSideEffect).}: ...`. This is the new + preferred way of writing these, emphasizing their unsafe nature. + + +## Compiler changes + +- Specific warnings can now be turned into errors via `--warningAsError[X]:on|off`. +- The `define` and `undef` pragmas have been de-deprecated. +- New command: `nim r main.nim [args...]` which compiles and runs main.nim, and implies `--usenimcache` + so that the output is saved to $nimcache/main$exeExt, using the same logic as `nim c -r` to + avoid recompilations when sources don't change. + Example: + ```bash + nim r compiler/nim.nim --help # only compiled the first time + echo 'import os; echo getCurrentCompilerExe()' | nim r - # this works too + nim r compiler/nim.nim --fullhelp # no recompilation + nim r --nimcache:/tmp main # binary saved to /tmp/main + ``` +- `--hint:processing` is now supported and means `--hint:processing:on` + (likewise with other hints and warnings), which is consistent with all other bool flags. + (since 1.3.3). +- `nim doc -r main` and `nim rst2html -r main` now call `openDefaultBrowser`. +- Added the new hint `--hint:msgOrigin` will show where a compiler msg (hint|warning|error) + was generated; this helps in particular when it's non obvious where it came from + either because multiple locations generate the same message, or because the + message involves runtime formatting. +- Added the new flag `--backend:js|c|cpp|objc` (or -b:js etc), to change the backend; can be + used with any command (e.g. nim r, doc, check etc); safe to re-assign. +- Added the new flag `--doccmd:cmd` to pass additional flags for runnableExamples, + e.g.: `--doccmd:-d:foo --threads` + use `--doccmd:skip` to skip runnableExamples and rst test snippets. +- Added the new flag `--usenimcache` to output binary files to nimcache. +- `runnableExamples "-b:cpp -r:off": code` is now supported, allowing to override + how an example is compiled and run, for example to change the backend. +- `nim doc` now outputs under `$projectPath/htmldocs` when `--outdir` is unspecified + (with or without `--project`); passing `--project` now automatically generates + an index and enables search. + See [docgen](docgen.html#introduction-quick-start) for details. +- Removed the `--oldNewlines` switch. +- Removed the `--laxStrings` switch for mutating the internal zero terminator on strings. +- Removed the `--oldast` switch. +- Removed the `--oldgensym` switch. +- `$getType(untyped)` is now "untyped" instead of "expr", `$getType(typed)` is + now "typed" instead of "stmt". +- Sink inference is now disabled per default and has to enabled explicitly via + `--sinkInference:on`. *Note*: For the standard library sink inference remains + enabled. This change is most relevant for the `--gc:arc`, `--gc:orc` memory + management modes. + + +## Tool changes + +- `nimsuggest` now returns both the forward declaration and the + implementation location upon a `def` query. Previously the behavior was + to return the forward declaration only. + + +## Bugfixes + +- Fixed "repr() not available for uint{,8,16,32,64} under --gc:arc" + ([#13872](https://github.com/nim-lang/Nim/issues/13872)) +- Fixed "Critical: 1 completed Future, multiple await: Only 1 await will be awakened (the last one)" + ([#13889](https://github.com/nim-lang/Nim/issues/13889)) +- Fixed "crash on openarray interator with argument in stmtListExpr" + ([#13739](https://github.com/nim-lang/Nim/issues/13739)) +- Fixed "Some compilers on Windows don't work" + ([#13910](https://github.com/nim-lang/Nim/issues/13910)) +- Fixed "httpclient hangs if it recieves an HTTP 204 (No Content)" + ([#13894](https://github.com/nim-lang/Nim/issues/13894)) +- Fixed ""distinct uint64" type corruption on 32-bit, when using {.borrow.} operators" + ([#13902](https://github.com/nim-lang/Nim/issues/13902)) +- Fixed "Regression: impossible to use typed pragmas with proc types" + ([#13909](https://github.com/nim-lang/Nim/issues/13909)) +- Fixed "openssl wrapper corrupts stack on OpenSSL 1.1.1f + Android" + ([#13903](https://github.com/nim-lang/Nim/issues/13903)) +- Fixed "C compile error with --gc:arc on version 1.2.0 "unknown type name 'TGenericSeq'" + ([#13863](https://github.com/nim-lang/Nim/issues/13863)) +- Fixed "var return type for proc doesn't work at c++ backend" + ([#13848](https://github.com/nim-lang/Nim/issues/13848)) +- Fixed "TimeFormat() should raise an error but craches at compilation time" + ([#12864](https://github.com/nim-lang/Nim/issues/12864)) +- Fixed "gc:arc cannot fully support threadpool with FlowVar" + ([#13781](https://github.com/nim-lang/Nim/issues/13781)) +- Fixed "simple 'var openarray[char]' assignment crash when the openarray source is a local string and using gc:arc" + ([#14003](https://github.com/nim-lang/Nim/issues/14003)) +- Fixed "Cant use expressions with `when` in `type` sections." + ([#14007](https://github.com/nim-lang/Nim/issues/14007)) +- Fixed "`for a in MyEnum` gives incorrect results with enum with holes" + ([#14001](https://github.com/nim-lang/Nim/issues/14001)) +- Fixed "Trivial crash" + ([#12741](https://github.com/nim-lang/Nim/issues/12741)) +- Fixed "Enum with holes cannot be used as Table index" + ([#12834](https://github.com/nim-lang/Nim/issues/12834)) +- Fixed "spawn proc that uses typedesc crashes the compiler" + ([#14014](https://github.com/nim-lang/Nim/issues/14014)) +- Fixed "Docs Search `Results` box styling is not Dark Mode Friendly" + ([#13972](https://github.com/nim-lang/Nim/issues/13972)) +- Fixed "--gc:arc -d:useSysAssert undeclared identifier `cstderr` with newSeq" + ([#14038](https://github.com/nim-lang/Nim/issues/14038)) +- Fixed "issues in the manual" + ([#12486](https://github.com/nim-lang/Nim/issues/12486)) +- Fixed "Annoying warning: inherit from a more precise exception type like ValueError, IOError or OSError [InheritFromException]" + ([#14052](https://github.com/nim-lang/Nim/issues/14052)) +- Fixed "relativePath("foo", "/") and relativePath("/", "foo") is wrong" + ([#13222](https://github.com/nim-lang/Nim/issues/13222)) +- Fixed "[regression] `parseEnum` does not work anymore for enums with holes" + ([#14030](https://github.com/nim-lang/Nim/issues/14030)) +- Fixed "Exception types in the stdlib should inherit from `CatchableError` or `Defect`, not `Exception`" + ([#10288](https://github.com/nim-lang/Nim/issues/10288)) +- Fixed "Make debugSend and debugRecv procs public in smtp.nim" + ([#12189](https://github.com/nim-lang/Nim/issues/12189)) +- Fixed "xmltree need add raw text, when add style element" + ([#14064](https://github.com/nim-lang/Nim/issues/14064)) +- Fixed "raises requirement does not propagate to derived methods" + ([#8481](https://github.com/nim-lang/Nim/issues/8481)) +- Fixed "tests/stdlib/tgetaddrinfo.nim fails on NetBSD" + ([#14091](https://github.com/nim-lang/Nim/issues/14091)) +- Fixed "tests/niminaction/Chapter8/sdl/sdl_test.nim fails on NetBSD" + ([#14088](https://github.com/nim-lang/Nim/issues/14088)) +- Fixed "Incorrect escape sequence for example in jsffi library documentation" + ([#14110](https://github.com/nim-lang/Nim/issues/14110)) +- Fixed "HCR: Can not link exported const, in external library" + ([#13915](https://github.com/nim-lang/Nim/issues/13915)) +- Fixed "Cannot import std/unidecode" + ([#14112](https://github.com/nim-lang/Nim/issues/14112)) +- Fixed "macOS: dsymutil should not be called on static libraries" + ([#14132](https://github.com/nim-lang/Nim/issues/14132)) +- Fixed "nim jsondoc -o:doc.json filename.nim fails when sequences without a type are used" + ([#14066](https://github.com/nim-lang/Nim/issues/14066)) +- Fixed "algorithm.sortedByIt template corrupts tuple input under --gc:arc" + ([#14079](https://github.com/nim-lang/Nim/issues/14079)) +- Fixed "Invalid C code with lvalue conversion" + ([#14160](https://github.com/nim-lang/Nim/issues/14160)) +- Fixed "strformat: doc example fails" + ([#14054](https://github.com/nim-lang/Nim/issues/14054)) +- Fixed "Nim doc fail to run for nim 1.2.0 (nim 1.0.4 is ok)" + ([#13986](https://github.com/nim-lang/Nim/issues/13986)) +- Fixed "Exception when converting csize to clong" + ([#13698](https://github.com/nim-lang/Nim/issues/13698)) +- Fixed "[Documentation] overloading using named arguments works but is not documented" + ([#11932](https://github.com/nim-lang/Nim/issues/11932)) +- Fixed "import os + use of existsDir/dirExists/existsFile/fileExists/findExe in config.nims causes "ambiguous call' error" + ([#14142](https://github.com/nim-lang/Nim/issues/14142)) +- Fixed "import os + use of existsDir/dirExists/existsFile/fileExists/findExe in config.nims causes "ambiguous call' error" + ([#14142](https://github.com/nim-lang/Nim/issues/14142)) +- Fixed "runnableExamples doc gen crashes compiler with `except Exception as e` syntax" + ([#14177](https://github.com/nim-lang/Nim/issues/14177)) +- Fixed "[ARC] Segfault with cyclic references (?)" + ([#14159](https://github.com/nim-lang/Nim/issues/14159)) +- Fixed "Semcheck regression when accessing a static parameter in proc" + ([#14136](https://github.com/nim-lang/Nim/issues/14136)) +- Fixed "iterator walkDir doesn't work with -d:useWinAnsi" + ([#14201](https://github.com/nim-lang/Nim/issues/14201)) +- Fixed "cas is wrong for tcc" + ([#14151](https://github.com/nim-lang/Nim/issues/14151)) +- Fixed "proc execCmdEx doesn't work with -d:useWinAnsi" + ([#14203](https://github.com/nim-lang/Nim/issues/14203)) +- Fixed "Use -d:nimEmulateOverflowChecks by default?" + ([#14209](https://github.com/nim-lang/Nim/issues/14209)) +- Fixed "Old sequences with destructor objects bug" + ([#14217](https://github.com/nim-lang/Nim/issues/14217)) +- Fixed "[ARC] ICE when changing the discriminant of a return value" + ([#14244](https://github.com/nim-lang/Nim/issues/14244)) +- Fixed "[ARC] ICE with static objects" + ([#14236](https://github.com/nim-lang/Nim/issues/14236)) +- Fixed "[ARC] "internal error: environment misses: a" in a finalizer" + ([#14243](https://github.com/nim-lang/Nim/issues/14243)) +- Fixed "[ARC] compile failure using repr with object containing `ref seq[string]`" + ([#14270](https://github.com/nim-lang/Nim/issues/14270)) +- Fixed "[ARC] implicit move on last use happening on non-last use" + ([#14269](https://github.com/nim-lang/Nim/issues/14269)) +- Fixed "[ARC] Compiler crash with a recursive non-ref object variant" + ([#14294](https://github.com/nim-lang/Nim/issues/14294)) +- Fixed "htmlparser.parseHtml behaves differently using --gc:arc or --gc:orc" + ([#13946](https://github.com/nim-lang/Nim/issues/13946)) +- Fixed "Invalid return value of openProcess is NULL rather than INVALID_HANDLE_VALUE(-1) in windows" + ([#14289](https://github.com/nim-lang/Nim/issues/14289)) +- Fixed "ARC codegen bug with inline iterators" + ([#14219](https://github.com/nim-lang/Nim/issues/14219)) +- Fixed "Building koch on OpenBSD fails unless the Nim directory is in `$PATH`" + ([#13758](https://github.com/nim-lang/Nim/issues/13758)) +- Fixed "[gc:arc] case object assignment SIGSEGV: destroy not called for primitive type " + ([#14312](https://github.com/nim-lang/Nim/issues/14312)) +- Fixed "Crash when using thread and --gc:arc " + ([#13881](https://github.com/nim-lang/Nim/issues/13881)) +- Fixed "Getting "Warning: Cannot prove that 'result' is initialized" for an importcpp'd proc with `var T` return type" + ([#14314](https://github.com/nim-lang/Nim/issues/14314)) +- Fixed "`nim cpp -r --gc:arc` segfaults on caught AssertionError" + ([#13071](https://github.com/nim-lang/Nim/issues/13071)) +- Fixed "tests/async/tasyncawait.nim is recently very flaky" + ([#14320](https://github.com/nim-lang/Nim/issues/14320)) +- Fixed "Documentation nonexistent quitprocs module" + ([#14331](https://github.com/nim-lang/Nim/issues/14331)) +- Fixed "SIGSEV encountered when creating threads in a loop w/ --gc:arc" + ([#13935](https://github.com/nim-lang/Nim/issues/13935)) +- Fixed "nim-gdb is missing from all released packages" + ([#13104](https://github.com/nim-lang/Nim/issues/13104)) +- Fixed "sysAssert error with gc:arc on 3 line program" + ([#13862](https://github.com/nim-lang/Nim/issues/13862)) +- Fixed "compiler error with inline async proc and pragma" + ([#13998](https://github.com/nim-lang/Nim/issues/13998)) +- Fixed "[ARC] Compiler crash when adding to a seq[ref Object]" + ([#14333](https://github.com/nim-lang/Nim/issues/14333)) +- Fixed "nimvm: sysFatal: unhandled exception: 'sons' is not accessible using discriminant 'kind' of type 'TNode' [FieldError]" + ([#14340](https://github.com/nim-lang/Nim/issues/14340)) +- Fixed "[Regression] karax events are not firing " + ([#14350](https://github.com/nim-lang/Nim/issues/14350)) +- Fixed "odbcsql module has some wrong integer types" + ([#9771](https://github.com/nim-lang/Nim/issues/9771)) +- Fixed "db_sqlite needs sqlPrepared" + ([#13559](https://github.com/nim-lang/Nim/issues/13559)) +- Fixed "[Regression] `createThread` is not GC-safe" + ([#14370](https://github.com/nim-lang/Nim/issues/14370)) +- Fixed "Broken example on hot code reloading" + ([#14380](https://github.com/nim-lang/Nim/issues/14380)) +- Fixed "runnableExamples block with `except` on specified error fails with `nim doc`" + ([#12746](https://github.com/nim-lang/Nim/issues/12746)) +- Fixed "compiler as a library: findNimStdLibCompileTime fails to find system.nim" + ([#12293](https://github.com/nim-lang/Nim/issues/12293)) +- Fixed "5 bugs with importcpp exceptions" + ([#14369](https://github.com/nim-lang/Nim/issues/14369)) +- Fixed "Docs shouldn't collapse pragmas inside runnableExamples/code blocks" + ([#14174](https://github.com/nim-lang/Nim/issues/14174)) +- Fixed "Bad codegen/emit for hashes.hiXorLo in some contexts." + ([#14394](https://github.com/nim-lang/Nim/issues/14394)) +- Fixed "Boehm GC does not scan thread-local storage" + ([#14364](https://github.com/nim-lang/Nim/issues/14364)) +- Fixed "RVO not exception safe" + ([#14126](https://github.com/nim-lang/Nim/issues/14126)) +- Fixed "runnableExamples that are only compiled" + ([#10731](https://github.com/nim-lang/Nim/issues/10731)) +- Fixed "`foldr` raises IndexError when called on sequence" + ([#14404](https://github.com/nim-lang/Nim/issues/14404)) +- Fixed "moveFile does not overwrite destination file" + ([#14057](https://github.com/nim-lang/Nim/issues/14057)) +- Fixed "doc2 outputs in current work dir" + ([#6583](https://github.com/nim-lang/Nim/issues/6583)) +- Fixed "[docgen] proc doc comments silently omitted after 1st runnableExamples" + ([#9227](https://github.com/nim-lang/Nim/issues/9227)) +- Fixed "`nim doc --project` shows '@@/' instead of '../' for relative paths to submodules" + ([#14448](https://github.com/nim-lang/Nim/issues/14448)) +- Fixed "re, nre have wrong `start` semantics" + ([#14284](https://github.com/nim-lang/Nim/issues/14284)) +- Fixed "runnableExamples should preserve source code doc comments, strings, and (maybe) formatting" + ([#8871](https://github.com/nim-lang/Nim/issues/8871)) +- Fixed "`nim doc ..` fails when runnableExamples uses `$` [devel] [regression]" + ([#14485](https://github.com/nim-lang/Nim/issues/14485)) +- Fixed "`items` is 20%~30% slower than iteration via an index" + ([#14421](https://github.com/nim-lang/Nim/issues/14421)) +- Fixed "ARC: unreliable setLen " + ([#14495](https://github.com/nim-lang/Nim/issues/14495)) +- Fixed "lent is unsafe: after #14447 you can modify variables with "items" loop for sequences" + ([#14498](https://github.com/nim-lang/Nim/issues/14498)) +- Fixed "`var op = fn()` wrongly gives warning `ObservableStores` with `object of RootObj` type" + ([#14514](https://github.com/nim-lang/Nim/issues/14514)) +- Fixed "Compiler assertion" + ([#14562](https://github.com/nim-lang/Nim/issues/14562)) +- Fixed "Can't get `ord` of a value of a Range type in the JS backend " + ([#14570](https://github.com/nim-lang/Nim/issues/14570)) +- Fixed "js: can't take addr of param (including implicitly via `lent`)" + ([#14576](https://github.com/nim-lang/Nim/issues/14576)) +- Fixed "{.noinit.} ignored in for loop -> bad codegen for non-movable types" + ([#14118](https://github.com/nim-lang/Nim/issues/14118)) +- Fixed "generic destructor gives: `Error: unresolved generic parameter`" + ([#14315](https://github.com/nim-lang/Nim/issues/14315)) +- Fixed "Memory leak with arc gc" + ([#14568](https://github.com/nim-lang/Nim/issues/14568)) +- Fixed "escape analysis broken with `lent`" + ([#14557](https://github.com/nim-lang/Nim/issues/14557)) +- Fixed "`wrapWords` seems to ignore linebreaks when wrapping, leaving breaks in the wrong place" + ([#14579](https://github.com/nim-lang/Nim/issues/14579)) +- Fixed "`lent` gives wrong results with -d:release" + ([#14578](https://github.com/nim-lang/Nim/issues/14578)) +- Fixed "Nested await expressions regression: `await a(await expandValue())` doesnt compile" + ([#14279](https://github.com/nim-lang/Nim/issues/14279)) +- Fixed "windows CI docs fails with strange errors" + ([#14545](https://github.com/nim-lang/Nim/issues/14545)) +- Fixed "[CI] tests/async/tioselectors.nim flaky test for freebsd + OSX CI" + ([#13166](https://github.com/nim-lang/Nim/issues/13166)) +- Fixed "seq.setLen sometimes doesn't zero memory" + ([#14655](https://github.com/nim-lang/Nim/issues/14655)) +- Fixed "`nim dump` is roughly 100x slower in 1.3 versus 1.2" + ([#14179](https://github.com/nim-lang/Nim/issues/14179)) +- Fixed "Regression: devel docgen cannot generate document for method" + ([#14691](https://github.com/nim-lang/Nim/issues/14691)) +- Fixed "recently flaky tests/async/t7758.nim" + ([#14685](https://github.com/nim-lang/Nim/issues/14685)) +- Fixed "Bind no longer working in generic procs." + ([#11811](https://github.com/nim-lang/Nim/issues/11811)) +- Fixed "The pegs module doesn't work with generics!" + ([#14718](https://github.com/nim-lang/Nim/issues/14718)) +- Fixed "Defer is not properly working for asynchronous procedures." + ([#13899](https://github.com/nim-lang/Nim/issues/13899)) +- Fixed "Add an ARC test with threads in a loop" + ([#14690](https://github.com/nim-lang/Nim/issues/14690)) +- Fixed "[goto exceptions] {.noReturn.} pragma is not detected in a case expression" + ([#14458](https://github.com/nim-lang/Nim/issues/14458)) +- Fixed "[exceptions:goto] C compiler error with dynlib pragma calling a proc" + ([#14240](https://github.com/nim-lang/Nim/issues/14240)) +- Fixed "Cannot borrow var float64 in infix assignment" + ([#14440](https://github.com/nim-lang/Nim/issues/14440)) +- Fixed "lib/pure/memfiles.nim: compilation error with --taintMode:on" + ([#14760](https://github.com/nim-lang/Nim/issues/14760)) +- Fixed "newWideCString allocates a multiple of the memory needed" + ([#14750](https://github.com/nim-lang/Nim/issues/14750)) +- Fixed "Nim source archive install: 'install.sh' fails with error: cp: cannot stat 'bin/nim-gdb': No such file or directory" + ([#14748](https://github.com/nim-lang/Nim/issues/14748)) +- Fixed "`nim cpp -r tests/exception/t9657` hangs" + ([#10343](https://github.com/nim-lang/Nim/issues/10343)) +- Fixed "Detect tool fails on FreeBSD" + ([#14715](https://github.com/nim-lang/Nim/issues/14715)) +- Fixed "compiler crash: `findUnresolvedStatic` " + ([#14802](https://github.com/nim-lang/Nim/issues/14802)) +- Fixed "seq namespace (?) regression" + ([#4796](https://github.com/nim-lang/Nim/issues/4796)) +- Fixed "Possible out of bounds string access in std/colors parseColor and isColor" + ([#14839](https://github.com/nim-lang/Nim/issues/14839)) +- Fixed "compile error on latest devel with orc and ssl" + ([#14647](https://github.com/nim-lang/Nim/issues/14647)) +- Fixed "[minor] `$` wrong for type tuple" + ([#13432](https://github.com/nim-lang/Nim/issues/13432)) +- Fixed "Documentation missing on devel asyncftpclient" + ([#14846](https://github.com/nim-lang/Nim/issues/14846)) +- Fixed "nimpretty is confused with a trailing comma in enum definition" + ([#14401](https://github.com/nim-lang/Nim/issues/14401)) +- Fixed "Output arguments get ignored when compiling with --app:staticlib" + ([#12745](https://github.com/nim-lang/Nim/issues/12745)) +- Fixed "[ARC] destructive move destroys the object too early" + ([#14396](https://github.com/nim-lang/Nim/issues/14396)) +- Fixed "highlite.getNextToken() crashes if the buffer string is "echo "\""" + ([#14830](https://github.com/nim-lang/Nim/issues/14830)) +- Fixed "Memory corruption with --gc:arc with a seq of objects with an empty body." + ([#14472](https://github.com/nim-lang/Nim/issues/14472)) +- Fixed "Stropped identifiers don't work as field names in tuple literals" + ([#14911](https://github.com/nim-lang/Nim/issues/14911)) +- Fixed "Please revert my commit" + ([#14930](https://github.com/nim-lang/Nim/issues/14930)) +- Fixed "[ARC] C compiler error with inline iterators and imports" + ([#14864](https://github.com/nim-lang/Nim/issues/14864)) +- Fixed "AsyncHttpClient segfaults with gc:orc, possibly memory corruption" + ([#14402](https://github.com/nim-lang/Nim/issues/14402)) +- Fixed "[ARC] Template with a block evaluating to a GC'd value results in a compiler crash" + ([#14899](https://github.com/nim-lang/Nim/issues/14899)) +- Fixed "[ARC] Weird issue with if expressions and templates" + ([#14900](https://github.com/nim-lang/Nim/issues/14900)) +- Fixed "xmlparser does not compile on devel" + ([#14805](https://github.com/nim-lang/Nim/issues/14805)) +- Fixed "returning lent T from a var T param gives codegen errors or SIGSEGV" + ([#14878](https://github.com/nim-lang/Nim/issues/14878)) +- Fixed "[ARC] Weird issue with if expressions and templates" + ([#14900](https://github.com/nim-lang/Nim/issues/14900)) +- Fixed "threads:on + gc:orc + unittest = C compiler errors" + ([#14865](https://github.com/nim-lang/Nim/issues/14865)) +- Fixed "mitems, mpairs doesn't work at compile time anymore" + ([#12129](https://github.com/nim-lang/Nim/issues/12129)) +- Fixed "strange result from executing code in const expression" + ([#10465](https://github.com/nim-lang/Nim/issues/10465)) +- Fixed "Same warning printed 3 times" + ([#11009](https://github.com/nim-lang/Nim/issues/11009)) +- Fixed "type alias for generic typeclass doesn't work" + ([#4668](https://github.com/nim-lang/Nim/issues/4668)) +- Fixed "exceptions:goto Bug devel codegen lvalue NIM_FALSE=NIM_FALSE" + ([#14925](https://github.com/nim-lang/Nim/issues/14925)) +- Fixed "the --useVersion:1.0 no longer works in devel" + ([#14912](https://github.com/nim-lang/Nim/issues/14912)) +- Fixed "template declaration of iterator doesn't compile" + ([#4722](https://github.com/nim-lang/Nim/issues/4722)) +- Fixed "Compiler crash on type inheritance with static generic parameter and equality check" + ([#12571](https://github.com/nim-lang/Nim/issues/12571)) +- Fixed "Nim crashes while handling a cast in async circumstances." + ([#13815](https://github.com/nim-lang/Nim/issues/13815)) +- Fixed "[ARC] Internal compiler error when calling an iterator from an inline proc " + ([#14383](https://github.com/nim-lang/Nim/issues/14383)) +- Fixed ""Cannot instantiate" error when template uses generic type" + ([#5926](https://github.com/nim-lang/Nim/issues/5926)) +- Fixed "Different raises behaviour for newTerminal between Linux and Windows" + ([#12759](https://github.com/nim-lang/Nim/issues/12759)) +- Fixed "Expand on a type (that defines a proc type) in error message " + ([#6608](https://github.com/nim-lang/Nim/issues/6608)) +- Fixed "unittest require quits program with an exit code of 0" + ([#14475](https://github.com/nim-lang/Nim/issues/14475)) +- Fixed "Range type: Generics vs concrete type, semcheck difference." + ([#8426](https://github.com/nim-lang/Nim/issues/8426)) +- Fixed "[Macro] Type mismatch when parameter name is the same as a field" + ([#13253](https://github.com/nim-lang/Nim/issues/13253)) +- Fixed "Generic instantiation failure when converting a sequence of circular generic types to strings" + ([#10396](https://github.com/nim-lang/Nim/issues/10396)) +- Fixed "initOptParser ignores argument after value option with empty value." + ([#13086](https://github.com/nim-lang/Nim/issues/13086)) +- Fixed "[ARC] proc with both explicit and implicit return results in a C compiler error" + ([#14985](https://github.com/nim-lang/Nim/issues/14985)) +- Fixed "Alias type forgets implicit generic params depending on order" + ([#14990](https://github.com/nim-lang/Nim/issues/14990)) +- Fixed "[ARC] sequtils.insert has different behaviour between ARC/refc" + ([#14994](https://github.com/nim-lang/Nim/issues/14994)) +- Fixed "The documentation for "hot code reloading" references a non-existent npm package" + ([#13621](https://github.com/nim-lang/Nim/issues/13621)) +- Fixed "existsDir deprecated but breaking `dir` undeclared" + ([#15006](https://github.com/nim-lang/Nim/issues/15006)) +- Fixed "uri.decodeUrl crashes on incorrectly formatted input" + ([#14082](https://github.com/nim-lang/Nim/issues/14082)) +- Fixed "testament incorrectly reports time for tests, leading to wrong conclusions" + ([#14822](https://github.com/nim-lang/Nim/issues/14822)) +- Fixed "Calling peekChar with Stream returned from osproc.outputStream generate runtime error" + ([#14906](https://github.com/nim-lang/Nim/issues/14906)) +- Fixed "localPassC pragma should come *after* other flags" + ([#14194](https://github.com/nim-lang/Nim/issues/14194)) +- Fixed ""Could not load" dynamic library at runtime because of hidden dependency" + ([#2408](https://github.com/nim-lang/Nim/issues/2408)) +- Fixed "--gc:arc generate invalid code for {.global.} (`«nimErr_» in NIM_UNLIKELY`)" + ([#14480](https://github.com/nim-lang/Nim/issues/14480)) +- Fixed "Using `^` from stdlib/math along with converters gives a match for types that aren't SomeNumber" + ([#15033](https://github.com/nim-lang/Nim/issues/15033)) +- Fixed "[ARC] Weird exception behaviour from doAssertRaises" + ([#15026](https://github.com/nim-lang/Nim/issues/15026)) +- Fixed "[ARC] Compiler crash declaring a finalizer proc directly in 'new'" + ([#15044](https://github.com/nim-lang/Nim/issues/15044)) +- Fixed "[ARC] C compiler error when creating a var of a const seq" + ([#15036](https://github.com/nim-lang/Nim/issues/15036)) +- Fixed "code with named arguments in proc of winim/com can not been compiled" + ([#15056](https://github.com/nim-lang/Nim/issues/15056)) +- Fixed "javascript backend produces javascript code with syntax error in object syntax" + ([#14534](https://github.com/nim-lang/Nim/issues/14534)) +- Fixed "--gc:arc should be ignored in JS mode." + ([#14684](https://github.com/nim-lang/Nim/issues/14684)) +- Fixed "arc: C compilation error with imported global code using a closure iterator" + ([#12990](https://github.com/nim-lang/Nim/issues/12990)) +- Fixed "[ARC] Crash when modifying a string with mitems iterator" + ([#15052](https://github.com/nim-lang/Nim/issues/15052)) +- Fixed "[ARC] SIGSEGV when calling a closure as a tuple field in a seq" + ([#15038](https://github.com/nim-lang/Nim/issues/15038)) +- Fixed "pass varargs[seq[T]] to iterator give empty seq " + ([#12576](https://github.com/nim-lang/Nim/issues/12576)) +- Fixed "Compiler crashes when using string as object variant selector with else branch" + ([#14189](https://github.com/nim-lang/Nim/issues/14189)) +- Fixed "JS compiler error related to implicit return and return var type" + ([#11354](https://github.com/nim-lang/Nim/issues/11354)) +- Fixed "`nkRecWhen` causes internalAssert in semConstructFields" + ([#14698](https://github.com/nim-lang/Nim/issues/14698)) +- Fixed "Memory leaks with async (closure iterators?) under ORC" + ([#15076](https://github.com/nim-lang/Nim/issues/15076)) +- Fixed "strutil.insertSep() fails on negative numbers" + ([#11352](https://github.com/nim-lang/Nim/issues/11352)) +- Fixed "Constructing a uint64 range on a 32-bit machine leads to incorrect codegen" + ([#14616](https://github.com/nim-lang/Nim/issues/14616)) +- Fixed "heapqueue pushpop() proc doesn't compile" + ([#14139](https://github.com/nim-lang/Nim/issues/14139)) +- Fixed "[ARC] SIGSEGV when trying to swap in a literal/const string" + ([#15112](https://github.com/nim-lang/Nim/issues/15112)) +- Fixed "Defer and --gc:arc" + ([#15071](https://github.com/nim-lang/Nim/issues/15071)) +- Fixed "internal error: compiler/semobjconstr.nim(324, 20) example" + ([#15111](https://github.com/nim-lang/Nim/issues/15111)) +- Fixed "[ARC] Sequence "disappears" with a table inside of a table with an object variant" + ([#15122](https://github.com/nim-lang/Nim/issues/15122)) +- Fixed "[ARC] SIGSEGV with tuple assignment caused by cursor inference" + ([#15130](https://github.com/nim-lang/Nim/issues/15130)) +- Fixed "Issue with --gc:arc at compile time" + ([#15129](https://github.com/nim-lang/Nim/issues/15129)) +- Fixed "Writing an empty string to an AsyncFile raises an IndexDefect" + ([#15148](https://github.com/nim-lang/Nim/issues/15148)) +- Fixed "Compiler is confused about call convention of function with nested closure" + ([#5688](https://github.com/nim-lang/Nim/issues/5688)) +- Fixed "Nil check on each field fails in generic function" + ([#15101](https://github.com/nim-lang/Nim/issues/15101)) +- Fixed "{.nimcall.} convention won't avoid the creation of closures" + ([#8473](https://github.com/nim-lang/Nim/issues/8473)) +- Fixed "smtp.nim(161, 40) Error: type mismatch: got <typeof(nil)> but expected 'SslContext = void'" + ([#15177](https://github.com/nim-lang/Nim/issues/15177)) +- Fixed "[strscans] scanf doesn't match a single character with $+ if it's the end of the string" + ([#15064](https://github.com/nim-lang/Nim/issues/15064)) +- Fixed "Crash and incorrect return values when using readPasswordFromStdin on Windows." + ([#15207](https://github.com/nim-lang/Nim/issues/15207)) +- Fixed "Possible capture error with fieldPairs and genericParams" + ([#15221](https://github.com/nim-lang/Nim/issues/15221)) +- Fixed "The StmtList processing of template parameters can lead to unexpected errors" + ([#5691](https://github.com/nim-lang/Nim/issues/5691)) +- Fixed "[ARC] C compiler error when passing a var openArray to a sink openArray" + ([#15035](https://github.com/nim-lang/Nim/issues/15035)) +- Fixed "Inconsistent unsigned -> signed RangeDefect usage across integer sizes" + ([#15210](https://github.com/nim-lang/Nim/issues/15210)) +- Fixed "toHex results in RangeDefect exception when used with large uint64" + ([#15257](https://github.com/nim-lang/Nim/issues/15257)) +- Fixed "Arc sink arg crash" + ([#15238](https://github.com/nim-lang/Nim/issues/15238)) +- Fixed "SQL escape in db_mysql is not enough" + ([#15219](https://github.com/nim-lang/Nim/issues/15219)) +- Fixed "Mixing 'return' with expressions is allowed in 1.2" + ([#15280](https://github.com/nim-lang/Nim/issues/15280)) +- Fixed "os.getFileInfo() causes ICE with --gc:arc on Windows" + ([#15286](https://github.com/nim-lang/Nim/issues/15286)) +- Fixed "[ARC] Sequence "disappears" with a table inside of a table with an object variant" + ([#15122](https://github.com/nim-lang/Nim/issues/15122)) +- Fixed "Documentation regression jsre module missing" + ([#15183](https://github.com/nim-lang/Nim/issues/15183)) +- Fixed "CountTable.smallest/largest() on empty table either asserts or gives bogus answer" + ([#15021](https://github.com/nim-lang/Nim/issues/15021)) +- Fixed "[Regression] Parser regression" + ([#15305](https://github.com/nim-lang/Nim/issues/15305)) +- Fixed "[ARC] SIGSEGV with tuple unpacking caused by cursor inference" + ([#15147](https://github.com/nim-lang/Nim/issues/15147)) +- Fixed "LwIP/FreeRTOS compile error - missing SIGPIPE and more " + ([#15302](https://github.com/nim-lang/Nim/issues/15302)) +- Fixed "Memory leaks with async (closure iterators?) under ORC" + ([#15076](https://github.com/nim-lang/Nim/issues/15076)) +- Fixed "Bug compiling with --gc:arg or --gc:orc" + ([#15325](https://github.com/nim-lang/Nim/issues/15325)) +- Fixed "memory corruption in tmarshall.nim" + ([#9754](https://github.com/nim-lang/Nim/issues/9754)) +- Fixed "typed macros break generic proc definitions" + ([#15326](https://github.com/nim-lang/Nim/issues/15326)) +- Fixed "nim doc2 ignores --docSeeSrcUrl parameter" + ([#6071](https://github.com/nim-lang/Nim/issues/6071)) +- Fixed "The decodeData Iterator from cgi module crash" + ([#15369](https://github.com/nim-lang/Nim/issues/15369)) +- Fixed "|| iterator generates invalid code when compiling with --debugger:native" + ([#9710](https://github.com/nim-lang/Nim/issues/9710)) +- Fixed "Wrong number of variables" + ([#15360](https://github.com/nim-lang/Nim/issues/15360)) +- Fixed "Coercions with distinct types should traverse pointer modifiers transparently." + ([#7165](https://github.com/nim-lang/Nim/issues/7165)) +- Fixed "Error with distinct generic TableRef" + ([#6060](https://github.com/nim-lang/Nim/issues/6060)) +- Fixed "Support images in nim docgen" + ([#6430](https://github.com/nim-lang/Nim/issues/6430)) +- Fixed "Regression. Double sem check for procs." + ([#15389](https://github.com/nim-lang/Nim/issues/15389)) +- Fixed "uri.nim url with literal ipv6 address is printed wrong, and cannot parsed again" + ([#15333](https://github.com/nim-lang/Nim/issues/15333)) +- Fixed "[ARC] Object variant gets corrupted with cursor inference" + ([#15361](https://github.com/nim-lang/Nim/issues/15361)) +- Fixed "`nim doc ..` compiler crash (regression 0.19.6 => 1.0)" + ([#14474](https://github.com/nim-lang/Nim/issues/14474)) +- Fixed "cannot borrow result; what it borrows from is potentially mutated" + ([#15403](https://github.com/nim-lang/Nim/issues/15403)) +- Fixed "memory corruption for seq.add(seq) with gc:arc and d:useMalloc " + ([#14983](https://github.com/nim-lang/Nim/issues/14983)) +- Fixed "DocGen HTML output appears improperly when encountering text immediately after/before inline monospace; in some cases won't compile" + ([#11537](https://github.com/nim-lang/Nim/issues/11537)) +- Fixed "Deepcopy in arc crashes" + ([#15405](https://github.com/nim-lang/Nim/issues/15405)) +- Fixed "pop pragma takes invalid input" + ([#15430](https://github.com/nim-lang/Nim/issues/15430)) +- Fixed "tests/stdlib/tgetprotobyname fails on NetBSD" + ([#15452](https://github.com/nim-lang/Nim/issues/15452)) +- Fixed "defer doesnt work with block, break and await" + ([#15243](https://github.com/nim-lang/Nim/issues/15243)) +- Fixed "tests/stdlib/tssl failing on NetBSD" + ([#15493](https://github.com/nim-lang/Nim/issues/15493)) +- Fixed "strictFuncs doesn't seem to catch simple ref mutation" + ([#15508](https://github.com/nim-lang/Nim/issues/15508)) +- Fixed "Sizeof of case object is incorrect. Showstopper" + ([#15516](https://github.com/nim-lang/Nim/issues/15516)) +- Fixed "[ARC] Internal error when trying to use a parallel for loop" + ([#15512](https://github.com/nim-lang/Nim/issues/15512)) +- Fixed "[ARC] Type-bound assign op is not being generated" + ([#15510](https://github.com/nim-lang/Nim/issues/15510)) +- Fixed "[ARC] Crash when adding openArray proc argument to a local seq" + ([#15511](https://github.com/nim-lang/Nim/issues/15511)) +- Fixed "VM: const case object gets some fields zeroed out at runtime" + ([#13081](https://github.com/nim-lang/Nim/issues/13081)) +- Fixed "regression(1.2.6 => devel): VM: const case object field access gives: 'sons' is not accessible" + ([#15532](https://github.com/nim-lang/Nim/issues/15532)) +- Fixed "Csources: huge size increase (x2.3) in 0.20" + ([#12027](https://github.com/nim-lang/Nim/issues/12027)) +- Fixed "Out of date error message for GC options" + ([#15547](https://github.com/nim-lang/Nim/issues/15547)) +- Fixed "dbQuote additional escape regression" + ([#15560](https://github.com/nim-lang/Nim/issues/15560)) diff --git a/changelogs/changelog_1_6_0.md b/changelogs/changelog_1_6_0.md new file mode 100644 index 000000000..4a1047d20 --- /dev/null +++ b/changelogs/changelog_1_6_0.md @@ -0,0 +1,957 @@ +# v1.6.0 - 2021-10-14 + + + +# Major new features + +With so many new features, pinpointing the most salient ones is a subjective exercise, +but here are a select few: + + +## `iterable[T]` + +The `iterable[T]` type class was added to match called iterators, +which solves a number of long-standing issues related to iterators. +Example: + +```nim +iterator iota(n: int): int = + for i in 0..<n: yield i + +# previously, you'd need `untyped`, which caused other problems such as lack +# of type inference, overloading issues, and MCS. +template sumOld(a: untyped): untyped = # no type inference possible + var result: typeof(block:(for ai in a: ai)) + for ai in a: result += ai + result + +assert sumOld(iota(3)) == 0 + 1 + 2 + +# now, you can write: +template sum[T](a: iterable[T]): T = + # `template sum(a: iterable): auto =` would also be possible + var result: T + for ai in a: result += ai + result + +assert sum(iota(3)) == 0 + 1 + 2 # or `iota(3).sum` +``` + +In particular iterable arguments can now be used with the method call syntax. For example: +```nim +import std/[sequtils, os] +echo walkFiles("*").toSeq # now works +``` +See PR [#17196](https://github.com/nim-lang/Nim/pull/17196) for additional details. + + +## Strict effects + +The effect system was refined and there is a new `.effectsOf` annotation that does +explicitly what was previously done implicitly. See the +[manual](https://nim-lang.github.io/Nim/manual.html#effect-system-effectsof-annotation) +for more details. +To write code that is portable with older Nim versions, use this idiom: + +```nim +when defined(nimHasEffectsOf): + {.experimental: "strictEffects".} +else: + {.pragma: effectsOf.} + +proc mysort(s: seq; cmp: proc(a, b: T): int) {.effectsOf: cmp.} +``` + +To enable the new effect system, compile with `--experimental:strictEffects`. +See also [#18777](https://github.com/nim-lang/Nim/pull/18777) and RFC +[#408](https://github.com/nim-lang/RFCs/issues/408). + + +## Private imports and private field access + +A new import syntax `import foo {.all.}` now allows importing all symbols +(public or private) from `foo`. +This can be useful for testing purposes or for more flexibility in project organization. + +Example: +```nim +from system {.all.} as system2 import nil +echo system2.ThisIsSystem # ThisIsSystem is private in `system` +import os {.all.} # weirdTarget is private in `os` +echo weirdTarget # or `os.weirdTarget` +``` + +Added a new module `std/importutils`, and an API `privateAccess`, which allows access +to private fields for an object type in the current scope. + +Example: +```nim +import times +from std/importutils import privateAccess +block: + let t = now() + # echo t.monthdayZero # Error: undeclared field: 'monthdayZero' for type times.DateTime + privateAccess(typeof(t)) # enables private access in this scope + echo t.monthdayZero # ok +``` + +See PR [#17706](https://github.com/nim-lang/Nim/pull/17706) for additional details. + + +## `nim --eval:cmd` + +Added `nim --eval:cmd` to evaluate a command directly, e.g.: `nim --eval:"echo 1"`. +It defaults to `e` (nimscript) but can also work with other commands, e.g.: +```bash +find . | nim r --eval:'import strutils; for a in stdin.lines: echo a.toUpper' +``` + +```bash +# use as a calculator: +nim --eval:'echo 3.1 / (1.2+7)' +# explore a module's APIs, including private symbols: +nim --eval:'import os {.all.}; echo weirdTarget' +# use a custom backend: +nim r -b:js --eval:"import std/jsbigints; echo 2'big ** 64'big" +``` + +See PR [#15687](https://github.com/nim-lang/Nim/pull/15687) for more details. + + +## Round-trip float to string + +`system.addFloat` and `system.$` now can produce string representations of +floating point numbers that are minimal in size and possess round-trip and correct +rounding guarantees (via the +[Dragonbox](https://raw.githubusercontent.com/jk-jeon/dragonbox/master/other_files/Dragonbox.pdf) algorithm). +This currently has to be enabled via `-d:nimPreviewFloatRoundtrip`. +It is expected that this behavior becomes the new default in upcoming versions, +as with other `nimPreviewX` define flags. + +Example: +```nim +from math import round +let a = round(9.779999999999999, 2) +assert a == 9.78 +echo a # with `-d:nimPreviewFloatRoundtrip`: 9.78, like in python3 (instead of 9.779999999999999) +``` + + +## New `std/jsbigints` module + +Provides arbitrary precision integers for the JS target. See PR +[#16409](https://github.com/nim-lang/Nim/pull/16409). +Example: +```nim +import std/jsbigints +assert 2'big ** 65'big == 36893488147419103232'big +echo 0xdeadbeef'big shl 4'big # 59774856944n +``` + + +## New `std/sysrand` module +Cryptographically secure pseudorandom number generator, +allows generating random numbers from a secure source provided by the operating system. +Example: +```nim +import std/sysrand +assert urandom(1234) != urandom(1234) # unlikely to fail in practice +``` +See PR [#16459](https://github.com/nim-lang/Nim/pull/16459). + + +## New module: `std/tempfiles` + +Allows creating temporary files and directories, see PR +[#17361](https://github.com/nim-lang/Nim/pull/17361) and followups. +```nim +import std/tempfiles +let tmpPath = genTempPath("prefix", "suffix.log", "/tmp/") +# tmpPath looks like: /tmp/prefixpmW1P2KLsuffix.log + +let dir = createTempDir("tmpprefix_", "_end") +# created dir looks like: getTempDir() / "tmpprefix_YEl9VuVj_end" + +let (cfile, path) = createTempFile("tmpprefix_", "_end.tmp") +# path looks like: getTempDir() / "tmpprefix_FDCIRZA0_end.tmp" +cfile.write "foo" +cfile.setFilePos 0 +assert readAll(cfile) == "foo" +close cfile +assert readFile(path) == "foo" +``` + + +## User-defined literals + +Custom numeric literals (e.g. `-128'bignum`) are now supported. +Additionally, the unary minus in `-1` is now part of the integer literal, i.e. +it is now parsed as a single token. +This implies that edge cases like `-128'i8` finally work correctly. +Example: +```nim +func `'big`*(num: cstring): JsBigInt {.importjs: "BigInt(#)".} +assert 0xffffffffffffffff'big == (1'big shl 64'big) - 1'big +``` + + +## Dot-like operators + +With `-d:nimPreviewDotLikeOps`, dot-like operators (operators starting with `.`, +but not with `..`) now have the same precedence as `.`, so that `a.?b.c` is now +parsed as `(a.?b).c` instead of `a.?(b.c)`. +A warning is generated when a dot-like operator is used without `-d:nimPreviewDotLikeOps`. + +An important use case is to enable dynamic fields without affecting the +built-in `.` operator, e.g. for `std/jsffi`, `std/json`, `pkg/nimpy`. Example: +```nim +import std/json +template `.?`(a: JsonNode, b: untyped{ident}): JsonNode = + a[astToStr(b)] +let j = %*{"a1": {"a2": 10}} +assert j.?a1.?a2.getInt == 10 +``` + + +## Block arguments now support optional parameters + +This solves a major pain point for routines accepting block parameters, +see PR [#18631](https://github.com/nim-lang/Nim/pull/18631) for details: + +```nim +template fn(a = 1, b = 2, body) = discard +fn(1, 2): # already works + bar +fn(a = 1): # now works + bar +``` + +Likewise with multiple block arguments via `do`: +```nim +template fn(a = 1, b = 2, body1, body2) = discard +fn(a = 1): # now works + bar1 +do: + bar2 +``` + + +# Other new features + +## New and deprecated modules + +The following modules were added (they are discussed in the rest of the text): +- `std/enumutils` +- `std/genasts` +- `std/importutils` +- `std/jsbigints` +- `std/jsfetch` +- `std/jsformdata` +- `std/jsheaders` +- `std/packedsets` +- `std/setutils` +- `std/socketstreams` +- `std/strbasics` +- `std/sysrand` +- `std/tasks` +- `std/tempfiles` +- `std/vmutils` + +- Deprecated `std/mersenne`. +- Removed deprecated `std/iup` module from stdlib; it has already moved to + [nimble](https://github.com/nim-lang/iup). + + +## New `std/jsfetch` module + +Provides a wrapper for JS Fetch API. +Example: +```nim +# requires -d:nimExperimentalAsyncjsThen +import std/[jsfetch, asyncjs, jsconsole, jsffi, sugar] +proc fn {.async.} = + await fetch("https://api.github.com/users/torvalds".cstring) + .then((response: Response) => response.json()) + .then((json: JsObject) => console.log(json)) + .catch((err: Error) => console.log("Request Failed", err)) +discard fn() +``` + + +## New `std/tasks` module + +Provides basic primitives for creating parallel programs. +Example: +```nim +import std/tasks +var num = 0 +proc hello(a: int) = num+=a + +let b = toTask hello(13) # arguments must be isolated, see `std/isolation` +b.invoke() +assert num == 13 +b.invoke() # can be called again +assert num == 26 +``` + + +## New module: `std/genasts` + +Provides an API `genAst` that avoids the problems inherent with `quote do` and can +be used as a replacement. +Example showing how this could be used for writing a simplified version of `unittest.check`: +```nim +import std/[genasts, macros, strutils] +macro check2(cond: bool): untyped = + assert cond.kind == nnkInfix, "$# not implemented" % $cond.kind + result = genAst(cond, s = repr(cond), lhs = cond[1], rhs = cond[2]): + # each local symbol we access must be explicitly captured + if not cond: + doAssert false, "'$#'' failed: lhs: '$#', rhs: '$#'" % [s, $lhs, $rhs] +let a = 3 +check2 a*2 == a+3 +if false: check2 a*2 < a+1 # would error with: 'a * 2 < a + 1'' failed: lhs: '6', rhs: '4' +``` + +See PR [#17426](https://github.com/nim-lang/Nim/pull/17426) for details. + + +## New module: `std/setutils` + +- Added `setutils.toSet` that can take any iterable and convert it to a built-in `set`, + if the iterable yields a built-in settable type. +- Added `setutils.fullSet` which returns a full built-in `set` for a valid type. +- Added `setutils.complement` which returns the complement of a built-in `set`. +- Added `setutils.[]=`. + + +## New module: `std/enumutils` + +- Added `genEnumCaseStmt` macro that generates + case statement to parse string to enum. +- Added `items` for enums with holes. +- Added `symbolName` to return the `enum` symbol name ignoring the human-readable name. +- Added `symbolRank` to return the index in which an `enum` member is listed in an enum. + + +## `system` + +- Added `system.prepareMutation` for better support of low + level `moveMem`, `copyMem` operations for `gc:orc`'s copy-on-write string + implementation. +- `system.addEscapedChar` now renders `\r` as `\r` instead of `\c`, to be compatible + with most other languages. +- Added `cmpMem` to `system`. +- `doAssertRaises` now correctly handles foreign exceptions. +- `addInt` now supports unsigned integers. + +Compatibility notes: +- `system.delete` had surprising behavior when the index passed to it was out of + bounds (it would delete the last entry then). Compile with `-d:nimStrictDelete` so + that an index error is produced instead. Be aware however that your code might depend on + this quirky behavior so a review process is required on your part before you can + use `-d:nimStrictDelete`. To make this review easier, use the `-d:nimAuditDelete` + switch, which pretends that `system.delete` is deprecated so that it is easier + to see where it was used in your code. + `-d:nimStrictDelete` will become the default in upcoming versions. +- `cuchar` is now deprecated as it aliased `char` where arguably it should have aliased `uint8`. + Please use `char` or `uint8` instead. +- `repr` now doesn't insert trailing newlines; the previous behavior was very inconsistent, + see [#16034](https://github.com/nim-lang/Nim/pull/16034). + Use `-d:nimLegacyReprWithNewline` for the previous behavior. + `repr` now also renders ASTs correctly for user defined literals, setters, `do`, etc. +- Deprecated `any`. See RFC [#281](https://github.com/nim-lang/RFCs/issues/281). +- The unary slice `..b` was deprecated, use `0..b` instead. + + +## `std/math` + +- Added `almostEqual` for comparing two float values using a machine epsilon. +- Added `clamp` which allows using a `Slice` to clamp to a value. +- Added `ceilDiv` for integer division that rounds up. +- Added `isNaN`. +- Added `copySign`. +- Added `euclDiv` and `euclMod`. +- Added `signbit`. +- Added `frexp` overload procs. Deprecated `c_frexp`, use `frexp` instead. + +Compatibility notes: +- `math.round` now rounds "away from zero" in the JS backend, which is consistent + with other backends. See [#9125](https://github.com/nim-lang/Nim/pull/9125). + Use `-d:nimLegacyJsRound` for the previous behavior. + + +## Random number generators: `std/random`, `std/sysrand`, `std/oids` + +- Added `std/sysrand` module (see details above). +- Added `randState` template that exposes the default random number generator. + Useful for library authors. +- Added `initRand()` overload with no argument which uses the current time as a seed. +- `initRand(seed)` now allows `seed == 0`. +- Fixed overflow bugs. +- Fix `initRand` to avoid random number sequences overlapping, refs + [#18744](https://github.com/nim-lang/Nim/pull/18744). +- `std/oids` now uses `std/random`. + +Compatibility notes: +- Deprecated `std/mersenne`. +- `random.initRand(seed)` now produces non-skewed values for the first call to + `rand()` after initialization with a small (< 30000) seed. + Use `-d:nimLegacyRandomInitRand` to restore previous behavior for a transition + time, see PR [#17467](https://github.com/nim-lang/Nim/pull/17467). + + +## `std/json`, `std/jsonutils` + +- With `-d:nimPreviewJsonutilsHoleyEnum`, `jsonutils` now can serialize/deserialize + holey enums as regular enums (via `ord`) instead of as strings. + It is expected that this behavior becomes the new default in upcoming versions. + `toJson` now serializes `JsonNode` as is via reference (without a deep copy) + instead of treating `JsonNode` as a regular ref object, + this can be customized via `jsonNodeMode`. +- `std/json` and `std/jsonutils` now serialize `NaN`, `Inf`, `-Inf` as strings, + so that `%[NaN, -Inf]` is the string `["nan","-inf"]` instead of `[nan,-inf]` + which was invalid JSON. +- `std/json` can now handle integer literals and floating point literals of + arbitrary length and precision. + Numbers that do not fit the underlying `BiggestInt` or `BiggestFloat` fields are + kept as string literals and one can use external BigNum libraries to handle these. + The `parseFloat` family of functions also has now optional `rawIntegers` and + `rawFloats` parameters that can be used to enforce that all integer or float + literals remain in the "raw" string form so that client code can easily treat + small and large numbers uniformly. +- Added `BackwardsIndex` overload for `JsonNode`. +- `json.%`,`json.to`, `jsonutils.fromJson`,`jsonutils.toJson` now work with `uint|uint64` + instead of raising (as in 1.4) or giving wrong results (as in 1.2). +- `std/jsonutils` now handles `cstring` (including as Table key), and `set`. +- Added `jsonutils.jsonTo` overload with `opt = Joptions()` param. +- `jsonutils.toJson` now supports customization via `ToJsonOptions`. +- `std/json`, `std/jsonutils` now support round-trip serialization when + `-d:nimPreviewFloatRoundtrip` is used. + + +## `std/typetraits`, `std/compilesettings` + +- `distinctBase` now is identity instead of error for non distinct types. +- `distinctBase` now allows controlling whether to be recursive or not. +- Added `enumLen` to return the number of elements in an enum. +- Added `HoleyEnum` for enums with holes, `OrdinalEnum` for enums without holes. +- Added `hasClosure`. +- Added `pointerBase` to return `T` for `ref T | ptr T`. +- Added `compilesettings.SingleValueSetting.libPath`. + + +## networking: `std/net`, `std/asyncnet`, `std/htmlgen`, `std/httpclient`, `std/asyncdispatch`, `std/asynchttpserver`, `std/httpcore` + +- Fixed buffer overflow bugs in `std/net`. +- Exported `sslHandle` from `std/net` and `std/asyncnet`. +- Added `hasDataBuffered` to `std/asyncnet`. +- Various functions in `std/httpclient` now accept `url` of type `Uri`. + Moreover, the `request` function's `httpMethod` argument of type `string` was + deprecated in favor of `HttpMethod` `enum` type; see + [#15919](https://github.com/nim-lang/Nim/pull/15919). +- Added `asyncdispatch.activeDescriptors` that returns the number of currently + active async event handles/file descriptors. +- Added `getPort` to `std/asynchttpserver` to resolve OS-assigned `Port(0)`; + this is usually recommended instead of hardcoding ports which can lead to + "Address already in use" errors. +- Fixed premature garbage collection in `std/asyncdispatch`, when a stacktrace + override is in place. +- Added `httpcore.is1xx` and missing HTTP codes. +- Added `htmlgen.portal` for [making "SPA style" pages using HTML only](https://web.dev/hands-on-portals). + +Compatibility notes: +- On Windows, the SSL library now checks for valid certificates. + For this purpose it uses the `cacert.pem` file, which was extracted + from `https://curl.se/ca/cacert.pem`. Besides + the OpenSSL DLLs (e.g. `libssl-1_1-x64.dll`, `libcrypto-1_1-x64.dll`) you + now also need to ship `cacert.pem` with your `.exe` file. + + +## `std/hashes` + +- `hashes.hash` can now support `object` and `ref` (can be overloaded in user code), + if `-d:nimPreviewHashRef` is used. It is expected that this behavior + becomes the new default in upcoming versions. +- `hashes.hash(proc|ptr|ref|pointer)` now calls `hash(int)` and honors `-d:nimIntHash1`. + `hashes.hash(closure)` has also been improved. + + +## OS: `std/os`, `std/io`, `std/socketstream`, `std/linenoise`, `std/tempfiles` + +- `os.FileInfo` (returned by `getFileInfo`) now contains `blockSize`, + determining preferred I/O block size for this file object. +- Added `os.getCacheDir()` to return platform specific cache directory. +- Improved `os.getTempDir()`, see PR [#16914](https://github.com/nim-lang/Nim/pull/16914). +- Added `os.isAdmin` to tell whether the caller's process is a member of the + Administrators local group (on Windows) or a root (on POSIX). +- Added optional `options` argument to `copyFile`, `copyFileToDir`, and + `copyFileWithPermissions`. By default, on non-Windows OSes, symlinks are + followed (copy files symlinks point to); on Windows, `options` argument is + ignored and symlinks are skipped. +- On non-Windows OSes, `copyDir` and `copyDirWithPermissions` copy symlinks as + symlinks (instead of skipping them as it was before); on Windows symlinks are + skipped. +- On non-Windows OSes, `moveFile` and `moveDir` move symlinks as symlinks + (instead of skipping them sometimes as it was before). +- Added optional `followSymlinks` argument to `setFilePermissions`. +- Added a simpler to use `io.readChars` overload. +- Added `socketstream` module that wraps sockets in the stream interface. +- Added experimental `linenoise.readLineStatus` to get line and status (e.g. ctrl-D or ctrl-C). + + +## Environment variable handling + +- Empty environment variable values are now supported across OS's and backends. +- Environment variable APIs now work in multithreaded scenarios, by delegating to + direct OS calls instead of trying to keep track of the environment. +- `putEnv`, `delEnv` now work at compile time. +- NodeJS backend now supports osenv: `getEnv`, `putEnv`, `envPairs`, `delEnv`, `existsEnv`. + +Compatibility notes: +- `std/os`: `putEnv` now raises if the first argument contains a `=`. + + +## POSIX + +- On POSIX systems, the default signal handlers used for Nim programs (it's + used for printing the stacktrace on fatal signals) will now re-raise the + signal for the OS default handlers to handle. + This lets the OS perform its default actions, which might include core + dumping (on select signals) and notifying the parent process about the cause + of termination. +- On POSIX systems, we now ignore `SIGPIPE` signals, use `-d:nimLegacySigpipeHandler` + for previous behavior. +- Added `posix_utils.osReleaseFile` to get system identification from `os-release` + file on Linux and the BSDs. + ([link](https://www.freedesktop.org/software/systemd/man/os-release.html)) +- Removed undefined behavior for `posix.open`. + + +## `std/prelude` + +- `std/strformat` is now part of `include std/prelude`. +- Added `std/sequtils` import to `std/prelude`. +- `std/prelude` now works with the JS target. +- `std/prelude` can now be used via `include std/prelude`, but `include prelude` still works. + + +## String manipulation: `std/strformat`, `std/strbasics` + +- Added support for parenthesized expressions. +- Added support for const strings instead of just string literals. +- Added `std/strbasics` for high-performance string operations. +- Added `strip`, `setSlice`, `add(a: var string, b: openArray[char])`. + + +## `std/wrapnils` + +- `std/wrapnils` doesn't use `experimental:dotOperators` anymore, avoiding + issues like bug [#13063](https://github.com/nim-lang/Nim/issues/13063) + (which affected error messages) for modules importing `std/wrapnils`. +- Added `??.` macro which returns an `Option`. +- `std/wrapnils` can now be used to protect against `FieldDefect` errors in + case objects, generates optimal code (no overhead compared to manual + if-else branches), and preserves lvalue semantics which allows modifying + an expression. + + +## Containers: `std/algorithm`, `std/lists`, `std/sequtils`, `std/options`, `std/packedsets` + +- Removed the optional `longestMatch` parameter of the `critbits._WithPrefix` + iterators (it never worked reliably). +- Added `algorithm.merge`. +- In `std/lists`: renamed `append` to `add` and retained `append` as an alias; + added `prepend` and `prependMoved` analogously to `add` and `addMoved`; + added `remove` for `SinglyLinkedList`s. +- Added new operations for singly- and doubly linked lists: `lists.toSinglyLinkedList` + and `lists.toDoublyLinkedList` convert from `openArray`s; `lists.copy` implements + shallow copying; `lists.add` concatenates two lists - an O(1) variation that consumes + its argument, `addMoved`, is also supplied. + See PRs [#16362](https://github.com/nim-lang/Nim/pull/16362), + [#16536](https://github.com/nim-lang/Nim/pull/16536). +- New module: `std/packedsets`. + Generalizes `std/intsets`, see PR [#15564](https://github.com/nim-lang/Nim/pull/15564). + +Compatibility notes: +- Deprecated `sequtils.delete` and added an overload taking a `Slice` that raises + a defect if the slice is out of bounds, likewise with `strutils.delete`. +- Deprecated `proc reversed*[T](a: openArray[T], first: Natural, last: int): seq[T]` + in `std/algorithm`. +- `std/options` changed `$some(3)` to `"some(3)"` instead of `"Some(3)"` + and `$none(int)` to `"none(int)"` instead of `"None[int]"`. + + +## `std/times` + +- Added `ZZZ` and `ZZZZ` patterns to `times.nim` `DateTime` parsing, to match time + zone offsets without colons, e.g. `UTC+7 -> +0700`. +- Added `dateTime` and deprecated `initDateTime`. + + +## `std/macros` and AST + +- New module `std/genasts`, see description above. +- The required name of case statement macros for the experimental + `caseStmtMacros` feature has changed from `match` to `` `case` ``. +- Tuple expressions are now parsed consistently as + `nnkTupleConstr` node. Will affect macros expecting nodes to be of `nnkPar`. +- In `std/macros`, `treeRepr,lispRepr,astGenRepr` now represent SymChoice nodes + in a collapsed way. + Use `-d:nimLegacyMacrosCollapseSymChoice` to get the previous behavior. +- Made custom op in `macros.quote` work for all statements. + + +## `std/sugar` + +- Added `sugar.dumpToString` which improves on `sugar.dump`. +- Added an overload for the `collect` macro that infers the container type based + on the syntax of the last expression. Works with std seqs, tables and sets. + +Compatibility notes: +- Removed support for named procs in `sugar.=>`. + + +## Parsing: `std/parsecfg`, `std/strscans`, `std/uri` + +- Added `sections` iterator in `parsecfg`. +- `strscans.scanf` now supports parsing single characters. +- Added `strscans.scanTuple` which uses `strscans.scanf` internally, + returning a tuple which can be unpacked for easier usage of `scanf`. +- Added `decodeQuery` to `std/uri`. +- `parseopt.initOptParser` has been made available and `parseopt` has been + added back to `std/prelude` for all backends. Previously `initOptParser` was + unavailable if the `std/os` module did not have `paramCount` or `paramStr`, + but the use of these in `initOptParser` were conditionally to the runtime + arguments passed to it, so `initOptParser` has been changed to raise + `ValueError` when the real command line is not available. `parseopt` was + previously excluded from `std/prelude` for JS, as it could not be imported. + +Compatibility notes: +- Changed the behavior of `uri.decodeQuery` when there are unencoded `=` + characters in the decoded values. Prior versions would raise an error. This is + no longer the case to comply with the HTML spec and other languages' + implementations. Old behavior can be obtained with + `-d:nimLegacyParseQueryStrict`. `cgi.decodeData` which uses the same + underlying code is also updated the same way. + + +## JS stdlib changes + +- Added `std/jsbigints` module, which provides arbitrary precision integers for the JS target. +- Added `setCurrentException` for the JS backend. +- `writeStackTrace` is available in the JS backend now. +- Added `then`, `catch` to `std/asyncjs` for promise pipelining, for now hidden + behind `-d:nimExperimentalAsyncjsThen`. +- Added `std/jsfetch` module [Fetch](https://developer.mozilla.org/docs/Web/API/Fetch_API) + wrapper for the JS target. +- Added `std/jsheaders` module [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers) + wrapper for the JS target. +- Added `std/jsformdata` module [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData) + wrapper for the JS target. +- Added `jscore.debugger` to [call any available debugging functionality, such as breakpoints](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/debugger). +- Added `jsconsole.dir`, `jsconsole.dirxml`, `jsconsole.timeStamp`. +- Added dollar `$` and `len` for `jsre.RegExp`. +- Added `jsconsole.jsAssert` for the JS target. +- Added `**` to `std/jsffi`. +- Added `copyWithin` [for `seq` and `array` for JS targets](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin). +- In `std/dom`, `Interval` is now a `ref object`, same as `Timeout`. + Definitions of `setTimeout`, `clearTimeout`, `setInterval`, `clearInterval` were updated. +- Added `dom.scrollIntoView` proc with options. +- Added `dom.setInterval`, `dom.clearInterval` overloads. +- Merged `std/dom_extensions` into the `std/dom` module, + as it was a module with a single line, see RFC [#413](https://github.com/nim-lang/RFCs/issues/413). +- `$` now gives more correct results on the JS backend. + + +## JS compiler changes + +- `cstring` doesn't support the `[]=` operator anymore in the JS backend. +- Array literals now use JS typed arrays when the corresponding JS typed array exists, + for example `[byte(1), 2, 3]` generates `new Uint8Array([1, 2, 3])`. + + +## VM and nimscript backend + +- VM now supports `addr(mystring[ind])` (index + index assignment). +- `nimscript` now handles `except Exception as e`. +- `nil` dereference is not allowed at compile time. `cast[ptr int](nil)[]` is rejected at compile time. +- `static[T]` now works better, refs [#17590](https://github.com/nim-lang/Nim/pull/17590), + [#15853](https://github.com/nim-lang/Nim/pull/15853). +- `distinct T` conversions now work in VM. +- `items(cstring)` now works in VM. +- Fix `addr`, `len`, `high` in VM ([#16002](https://github.com/nim-lang/Nim/pull/16002), + [#16610](https://github.com/nim-lang/Nim/pull/16610)). +- `std/cstrutils` now works in VM. + + +## OS/platform-specific notes + +- Support for Apple silicon/M1. +- Support for 32-bit RISC-V, refs [#16231](https://github.com/nim-lang/Nim/pull/16231). +- Support for armv8l, refs [#18901](https://github.com/nim-lang/Nim/pull/18901). +- Support for CROSSOS, refs [#18889](https://github.com/nim-lang/Nim/pull/18889). +- The allocator for Nintendo Switch, which was nonfunctional because + of breaking changes in libnx, was removed, in favor of the new `-d:nimAllocPagesViaMalloc` option. +- Allow reading parameters when compiling for Nintendo Switch. +- `--nimcache` now correctly works in a cross-compilation setting. +- Cross compilation targeting Windows was improved. +- This now works from macOS/Linux: `nim r -d:mingw main` + + + +## Performance / memory optimizations + +- The comment field in PNode AST was moved to a side channel, reducing overall + memory usage during compilation by a factor 1.25x +- `std/jsonutils` deserialization is now up to 20x faster. +- `os.copyFile` is now 2.5x faster on macOS, by using `copyfile` from `copyfile.h`; + use `-d:nimLegacyCopyFile` for macOS < 10.5. +- Float to string conversion is now 10x faster thanks to the Dragonbox algorithm, + with `-d:nimPreviewFloatRoundtrip`. +- `newSeqWith` is 3x faster. +- CI now supports batching (making Windows CI 2.3X faster). +- Sets now uses the optimized `countSetBits` proc, see PR + [#17334](https://github.com/nim-lang/Nim/pull/17334). + + +## Debugging + +- You can now enable/disable VM tracing in user code via `vmutils.vmTrace`. +- `koch tools` now builds `bin/nim_dbg` which allows easy access to a debug version + of Nim without recompiling. +- Added new module `compiler/debugutils` to help with debugging Nim compiler. +- Renamed `-d:nimCompilerStackraceHints` to `-d:nimCompilerStacktraceHints` and + used it in more contexts; this flag which works in tandem with `--stackTraceMsgs` + to show user code context in compiler stacktraces. + + +## Type system + +- `typeof(voidStmt)` now works and returns `void`. +- `enum` values can now be overloaded. This needs to be enabled + via `{.experimental: "overloadableEnums".}`. We hope that this feature allows + for the development of more fluent (less ugly) APIs. + See RFC [#373](https://github.com/nim-lang/RFCs/issues/373) for more details. +- A type conversion from one `enum` type to another now produces an `[EnumConv]` warning. + You should use `ord` (or `cast`, but the compiler won't help, if you misuse it) instead. + ```nim + type A = enum a1, a2 + type B = enum b1, b2 + echo a1.B # produces a warning + echo a1.ord.B # produces no warning + ``` +- A dangerous implicit conversion to `cstring` now triggers a `[CStringConv]` warning. + This warning will become an error in future versions! Use an explicit conversion + like `cstring(x)` in order to silence the warning. +- There is a new warning for *any* type conversion to `enum` that can be enabled via + `.warning[AnyEnumConv]:on` or `--warning:AnyEnumConv:on`. +- Reusing a type name in a different scope now works, refs [#17710](https://github.com/nim-lang/Nim/pull/17710). +- Fixed implicit and explicit generics in procedures, refs [#18808](https://github.com/nim-lang/Nim/pull/18808). + + +## New-style concepts + +Example: +```nim +type + Comparable = concept # no T, an atom + proc cmp(a, b: Self): int +``` +The new design does not rely on `system.compiles` and may compile faster. +See PR [#15251](https://github.com/nim-lang/Nim/pull/15251) +and RFC [#168](https://github.com/nim-lang/RFCs/issues/168) for details. + + +## Lexical / syntactic + +- Nim now supports a small subset of Unicode operators as operator symbols. + The supported symbols are: "∙ ∘ × ★ ⊗ ⊘ ⊙ ⊛ ⊠⊡ ∩ ∧ ⊓ ± ⊕ ⊖ ⊞ ⊟ ∪ ∨ ⊔". + To enable this feature, use `--experimental:unicodeOperators`. Note that due + to parser limitations you **cannot** enable this feature via a + pragma `{.experimental: "unicodeOperators".}` reliably, you need to enable + it via the command line or in a configuration file. +- `var a {.foo.} = expr` now works inside templates (except when `foo` is overloaded). + + +## Compiler messages, error messages, hints, warnings + +- Significant improvement to error messages involving effect mismatches, + see PRs [#18384](https://github.com/nim-lang/Nim/pull/18384), + [#18418](https://github.com/nim-lang/Nim/pull/18418). +- Added `--declaredLocs` to show symbol declaration location in error messages. +- Added `--spellSuggest` to show spelling suggestions on typos. +- Added `--processing:dots|filenames|off` which customizes `hintProcessing`; + `--processing:filenames` shows which include/import modules are being compiled as an import stack. +- `FieldDefect` messages now shows discriminant value + lineinfo, in all backends (C, JS, VM) +- Added `--hintAsError` with similar semantics as `--warningAsError`. +- Added `--unitsep:on|off` to control whether to add ASCII unit separator `\31` + before a newline for every generated message (potentially multiline), + so tooling can tell when messages start and end. +- Added `--filenames:abs|canonical|legacyRelProj` which replaces `--listFullPaths:on|off` +- `--hint:all:on|off` is now supported to select or deselect all hints; it + differs from `--hints:on|off` which acts as a (reversible) gate. + Likewise with `--warning:all:on|off`. +- The style checking of the compiler now supports a `--styleCheck:usages` switch. + This switch enforces that every symbol is written as it was declared, not enforcing + the official Nim style guide. To be enabled, this has to be combined either + with `--styleCheck:error` or `--styleCheck:hint`. +- Type mismatch errors now show more context, use `-d:nimLegacyTypeMismatch` for + previous behavior. +- `typedesc[Foo]` now renders as such instead of `type Foo` in compiler messages. +- `runnableExamples` now show originating location in stacktraces on failure. +- `SuccessX` message now shows more useful information. +- New `DuplicateModuleImport` warning; improved `UnusedImport` and + `XDeclaredButNotUsed` accuracy. + +Compatibility notes: +- `--hint:CC` now prints to stderr (like all other hints) instead of stdout. + + +## Building and running Nim programs, configuration system + +- JSON build instructions are now generated in `$nimcache/outFileBasename.json` + instead of `$nimcache/projectName.json`. This allows avoiding recompiling a + given project compiled with different options if the output file differs. +- `--usenimcache` (implied by `nim r main`) now generates an output file that includes + a hash of some of the compilation options, which allows caching generated binaries: + ```bash + nim r main # recompiles + nim r -d:foo main # recompiles + nim r main # uses cached binary + nim r main arg1 arg2 # likewise (runtime arguments are irrelevant) + ``` +- `nim r` now supports cross compilation from unix to windows when specifying + `-d:mingw` by using Wine, e.g.: + `nim r --eval:'import os; echo "a" / "b"'` prints `a\b`. +- `nim` can compile version 1.4.0 as follows: + `nim c --lib:lib --stylecheck:off -d:nimVersion140 compiler/nim`. + `-d:nimVersion140` is not needed for bootstrapping, only for building 1.4.0 from devel. +- `nim e` now accepts arbitrary file extensions for the nimscript file, + although `.nims` is still the preferred extension in general. +- The configuration subsystem now allows for `-d:release` and `-d:danger` to work as expected. + The downside is that these defines now have custom logic that doesn't apply for + other defines. + + +## Multithreading + +- TLS: macOS now uses native TLS (`--tlsEmulation:off`). TLS now works with + `importcpp` non-POD types; such types must use `.cppNonPod` and + `--tlsEmulation:off`should be used. +- Added `unsafeIsolate` and `extract` to `std/isolation`. +- Added `std/tasks`, see description above. + + +## Memory management + +- `--gc:arc` now bootstraps (PR [#17342](https://github.com/nim-lang/Nim/pull/17342)). +- Lots of improvements to `gc:arc`, `gc:orc`, see PR + [#15697](https://github.com/nim-lang/Nim/pull/15697), + [#16849](https://github.com/nim-lang/Nim/pull/16849), + [#17993](https://github.com/nim-lang/Nim/pull/17993). +- `--gc:orc` is now 10% faster than previously for common workloads. + If you have trouble with its changed behavior, compile with `-d:nimOldOrc`. +- The `--gc:orc` algorithm was refined so that custom container types can participate in the + cycle collection process. See the documentation of `=trace` for more details. +- On embedded devices `malloc` can now be used instead of `mmap` via `-d:nimAllocPagesViaMalloc`. + This is only supported for `--gc:orc` or `--gc:arc`. + +Compatibility notes: +- `--newruntime` and `--refchecks` are deprecated, + use `--gc:arc`, `--gc:orc`, or `--gc:none` as appropriate instead. + + +## Docgen + +- docgen: RST files can now use single backticks instead of double backticks and + correctly render in both `nim rst2html` (as before) as well as common tools rendering + RST directly (e.g. GitHub). + This is done by adding the `default-role:: code` directive inside the RST file + (which is now handled by `nim rst2html`). +- Source+Edit links now appear on top of every docgen'd page when + `nim doc --git.url:url ...` is given. +- Latex doc generation is revised: output `.tex` files should be compiled + by `xelatex` (not by `pdflatex` as before). Now default Latex settings + provide support for Unicode and better avoid margin overflows. + The minimum required version is TeXLive 2018 (or an equivalent MikTeX version). +- The RST parser now supports footnotes, citations, admonitions, and short style + references with symbols. +- The RST parser now supports Markdown table syntax. + Known limitations: + - cell alignment is not supported, i.e. alignment annotations in a delimiter + row (`:---`, `:--:`, `---:`) are ignored + - every table row must start with `|`, e.g. `| cell 1 | cell 2 |`. +- Implemented `doc2tex` compiler command which converts documentation in + `.nim` files to Latex. +- docgen now supports syntax highlighting for inline code. +- docgen now supports same-line doc comments: + ```nim + func fn*(a: int): int = 42 ## Doc comment + ``` +- docgen now renders `deprecated` and other pragmas. +- `runnableExamples` now works with templates and nested templates. +- `runnableExamples: "-r:off"` now works for examples that should compile but not run. +- `runnableExamples` now renders code verbatim, and produces correct code in all cases. +- docgen now shows correct, canonical import paths in docs. +- docgen now shows all routines in sidebar, and the proc signature is now shown in sidebar. + + +## Effects and checks + +- Significant improvement to error messages involving effect mismatches +- There is a new `cast` section `{.cast(uncheckedAssign).}: body` that disables some + compiler checks regarding `case objects`. This allows serialization libraries + to avoid ugly, non-portable solutions. See RFC + [#407](https://github.com/nim-lang/RFCs/issues/407) for more details. + +Compatibility notes: +- Fixed effect tracking for borrowed procs (see [#18882](https://github.com/nim-lang/Nim/pull/18882)). + One consequence is that, under some circumstances, Nim could previously permit a procedure with side effects to be written with `func` - you may need to change some occurrences of `func` to `proc`. + To illustrate, Nim versions before 1.6.0 compile the below without error + ```nim + proc print(s: string) = + echo s + + type + MyString = distinct string + + proc print(s: MyString) {.borrow.} + + func foo(s: MyString) = + print(s) + ``` + but Nim 1.6.0 produces the error + ``` + Error: 'foo' can have side effects + ``` + similar to how we expect that + ```nim + func print(s: string) = + echo s + ``` + produces + ``` + Error: 'print' can have side effects + ``` + + +## Tools + +- Major improvements to `nimgrep`, see PR [#15612 +](https://github.com/nim-lang/Nim/pull/15612). +- `fusion` is now un-bundled from Nim, `./koch fusion` will + install it via Nimble at a fixed hash. +- `testament`: added `nimoutFull: bool` spec to compare full output of compiler + instead of a subset; many bugfixes to testament. + + +## Misc/cleanups + +- Deprecated `TaintedString` and `--taintmode`. +- Deprecated `--nilseqs` which is now a noop. +- Added `-d:nimStrictMode` in CI in several places to ensure code doesn't have + certain hints/warnings. +- Removed `.travis.yml`, `appveyor.yml.disabled`, `.github/workflows/ci.yml.disabled`. +- `[skip ci]` now works in azure and CI pipelines, see detail in PR + [#17561](https://github.com/nim-lang/Nim/pull/17561). diff --git a/changelogs/changelog_2_0_0.md b/changelogs/changelog_2_0_0.md new file mode 100644 index 000000000..457cc62a6 --- /dev/null +++ b/changelogs/changelog_2_0_0.md @@ -0,0 +1,330 @@ +# v2.0.0 - 2023-08-01 + +Version 2.0 is a big milestone with too many changes to list them all here. + +For a full list see [details](changelog_2_0_0_details.html). + + +## New features + +### Better tuple unpacking + +Tuple unpacking for variables is now treated as syntax sugar that directly +expands into multiple assignments. Along with this, tuple unpacking for +variables can now be nested. + +```nim +proc returnsNestedTuple(): (int, (int, int), int, int) = (4, (5, 7), 2, 3) + +# Now nesting is supported! +let (x, (_, y), _, z) = returnsNestedTuple() + +``` + +### Improved type inference + +A new form of type inference called [top-down inference](https://nim-lang.github.io/Nim/manual_experimental.html#topminusdown-type-inference) has been implemented for a variety of basic cases. + +For example, code like the following now compiles: + +```nim +let foo: seq[(float, byte, cstring)] = @[(1, 2, "abc")] +``` + +### Forbidden Tags + +[Tag tracking](https://nim-lang.github.io/Nim/manual.html#effect-system-tag-tracking) now supports the definition +of forbidden tags by the `.forbids` pragma which can be used to disable certain effects in proc types. + +For example: + +```nim + +type IO = object ## input/output effect +proc readLine(): string {.tags: [IO].} = discard +proc echoLine(): void = discard + +proc no_IO_please() {.forbids: [IO].} = + # this is OK because it didn't define any tag: + echoLine() + # the compiler prevents this: + let y = readLine() + +``` + +### New standard library modules + +The famous `os` module got an overhaul. Several of its features are available +under a new interface that introduces a `Path` abstraction. A `Path` is +a `distinct string`, which improves the type safety when dealing with paths, files +and directories. + +Use: + +- `std/oserrors` for OS error reporting. +- `std/envvars` for environment variables handling. +- `std/paths` for path handling. +- `std/dirs` for directory creation/deletion/traversal. +- `std/files` for file existence checking, file deletions and moves. +- `std/symlinks` for symlink handling. +- `std/appdirs` for accessing configuration/home/temp directories. +- `std/cmdline` for reading command line parameters. + +### Consistent underscore handling + +The underscore identifier (`_`) is now generally not added to scope when +used as the name of a definition. While this was already the case for +variables, it is now also the case for routine parameters, generic +parameters, routine declarations, type declarations, etc. This means that the following code now does not compile: + +```nim +proc foo(_: int): int = _ + 1 +echo foo(1) + +proc foo[_](t: typedesc[_]): seq[_] = @[default(_)] +echo foo[int]() + +proc _() = echo "_" +_() + +type _ = int +let x: _ = 3 +``` + +Whereas the following code now compiles: + +```nim +proc foo(_, _: int): int = 123 +echo foo(1, 2) + +proc foo[_, _](): int = 123 +echo foo[int, bool]() + +proc foo[T, U](_: typedesc[T], _: typedesc[U]): (T, U) = (default(T), default(U)) +echo foo(int, bool) + +proc _() = echo "one" +proc _() = echo "two" + +type _ = int +type _ = float +``` + +### JavaScript codegen improvement + +The JavaScript backend now uses [BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) +for 64-bit integer types (`int64` and `uint64`) by default. As this affects +JS code generation, code using these types to interface with the JS backend +may need to be updated. Note that `int` and `uint` are not affected. + +For compatibility with [platforms that do not support BigInt](https://caniuse.com/bigint) +and in the case of potential bugs with the new implementation, the +old behavior is currently still supported with the command line option +`--jsbigint64:off`. + + +## Docgen improvements + +`Markdown` is now the default markup language of doc comments (instead +of the legacy `RstMarkdown` mode). In this release we begin to separate +RST and Markdown features to better follow specification of each +language, with the focus on Markdown development. +See also [the docs](https://nim-lang.github.io/Nim/markdown_rst.html). + +* Added a `{.doctype: Markdown | RST | RstMarkdown.}` pragma allowing to + select the markup language mode in the doc comments of the current `.nim` + file for processing by `nim doc`: + + 1. `Markdown` (default) is basically CommonMark (standard Markdown) + + some Pandoc Markdown features + some RST features that are missing + in our current implementation of CommonMark and Pandoc Markdown. + 2. `RST` closely follows the RST spec with few additional Nim features. + 3. `RstMarkdown` is a maximum mix of RST and Markdown features, which + is kept for the sake of compatibility and ease of migration. + +* Added separate `md2html` and `rst2html` commands for processing + standalone `.md` and `.rst` files respectively (and also `md2tex`/`rst2tex`). + +* Added Pandoc Markdown bracket syntax `[...]` for making anchor-less links. +* Docgen now supports concise syntax for referencing Nim symbols: + instead of specifying HTML anchors directly one can use original + Nim symbol declarations (adding the aforementioned link brackets + `[...]` around them). + * To use this feature across modules, a new `importdoc` directive was added. + Using this feature for referencing also helps to ensure that links + (inside one module or the whole project) are not broken. +* Added support for RST & Markdown quote blocks (blocks starting with `>`). +* Added a popular Markdown definition lists extension. +* Added Markdown indented code blocks (blocks indented by >= 4 spaces). +* Added syntax for additional parameters to Markdown code blocks: + + ```nim test="nim c $1" + ... + ``` + + +## C++ interop enhancements + +Nim 2.0 takes C++ interop to the next level. With the new [virtual](https://nim-lang.github.io/Nim/manual_experimental.html#virtual-pragma) pragma and the extended [constructor](https://nim-lang.github.io/Nim/manual_experimental.html#constructor-pragma) pragma. +Now one can define constructors and virtual procs that maps to C++ constructors and virtual methods, allowing one to further customize +the interoperability. There is also extended support for the [codeGenDecl](https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-codegendecl-pragma) pragma, so that it works on types. + +It's a common pattern in C++ to use inheritance to extend a library. Some even use multiple inheritance as a mechanism to make interfaces. + +Consider the following example: + +```cpp + +struct Base { + int someValue; + Base(int inValue) { + someValue = inValue; + }; +}; + +class IPrinter { +public: + virtual void print() = 0; +}; +``` + +```nim + +type + Base* {.importcpp, inheritable.} = object + someValue*: int32 + IPrinter* {.importcpp.} = object + +const objTemplate = """ + struct $1 : public $3, public IPrinter { + $2 + }; +"""; + +type NimChild {.codegenDecl: objTemplate .} = object of Base + +proc makeNimChild(val: int32): NimChild {.constructor: "NimClass('1 #1) : Base(#1)".} = + echo "It calls the base constructor passing " & $this.someValue + this.someValue = val * 2 # Notice how we can access `this` inside the constructor. It's of the type `ptr NimChild`. + +proc print*(self: NimChild) {.virtual.} = + echo "Some value is " & $self.someValue + +let child = makeNimChild(10) +child.print() +``` + +It outputs: + +``` +It calls the base constructor passing 10 +Some value is 20 +``` + + +## ARC/ORC refinements + +With the 2.0 release, the ARC/ORC model got refined once again and is now finally complete: + +1. Programmers now have control over the "item was moved from" state as `=wasMoved` is overridable. +2. There is a new `=dup` hook which is more efficient than the old combination of `=wasMoved(tmp); =copy(tmp, x)` operations. +3. Destructors now take a parameter of the attached object type `T` directly and don't have to take a `var T` parameter. + +With these important optimizations we improved the runtime of the compiler and important benchmarks by 0%! Wait ... what? +Yes, unfortunately it turns out that for a modern optimizer like in GCC or LLVM there is no difference. + +But! This refined model is more efficient once separate compilation enters the picture. In other words, as we think of +providing a stable ABI it is important not to lose any efficiency in the calling conventions. + + +## Tool changes + +- Nim now ships Nimble version 0.14 which added support for lock-files. Libraries are stored in `$nimbleDir/pkgs2` (it was `$nimbleDir/pkgs` before). Use `nimble develop --global` to create an old style link file in the special links directory documented at https://github.com/nim-lang/nimble#nimble-develop. +- nimgrep now offers the option `--inContext` (and `--notInContext`), which + allows to filter only matches with the context block containing a given pattern. +- nimgrep: names of options containing "include/exclude" are deprecated, + e.g. instead of `--includeFile` and `--excludeFile` we have + `--filename` and `--notFilename` respectively. + Also, the semantics are now consistent for such positive/negative filters. +- Nim now ships with an alternative package manager called Atlas. More on this in upcoming versions. + + +## Porting guide + +### Block and Break + +Using an unnamed break in a block is deprecated. This warning will become an error in future versions! Use a named block with a named break instead. In other words, turn: + +```nim + +block: + a() + if cond: + break + b() + +``` + +Into: + +```nim + +block maybePerformB: + a() + if cond: + break maybePerformB + b() + +``` + +### Strict funcs + +The definition of `"strictFuncs"` was changed. +The old definition was roughly: "A store to a ref/ptr deref is forbidden unless it's coming from a `var T` parameter". +The new definition is: "A store to a ref/ptr deref is forbidden." + +This new definition is much easier to understand, the price is some expressitivity. The following code used to be +accepted: + +```nim + +{.experimental: "strictFuncs".} + +type Node = ref object + s: string + +func create(s: string): Node = + result = Node() + result.s = s # store to result[] + +``` + +Now it has to be rewritten to: + +```nim + +{.experimental: "strictFuncs".} + +type Node = ref object + s: string + +func create(s: string): Node = + result = Node(s: s) + +``` + +### Standard library + +Several standard library modules have been moved to nimble packages, use `nimble` or `atlas` to install them: + +- `std/punycode` => `punycode` +- `std/asyncftpclient` => `asyncftpclient` +- `std/smtp` => `smtp` +- `std/db_common` => `db_connector/db_common` +- `std/db_sqlite` => `db_connector/db_sqlite` +- `std/db_mysql` => `db_connector/db_mysql` +- `std/db_postgres` => `db_connector/db_postgres` +- `std/db_odbc` => `db_connector/db_odbc` +- `std/md5` => `checksums/md5` +- `std/sha1` => `checksums/sha1` +- `std/sums` => `sums` diff --git a/changelogs/changelog_2_0_0_details.md b/changelogs/changelog_2_0_0_details.md new file mode 100644 index 000000000..24dc4edad --- /dev/null +++ b/changelogs/changelog_2_0_0_details.md @@ -0,0 +1,560 @@ +# v2.0.0 - 2023-08-01 + + +## Changes affecting backward compatibility + +- ORC is now the default memory management strategy. Use + `--mm:refc` for a transition period. + +- The `threads:on` option is now the default. + +- `httpclient.contentLength` default to `-1` if the Content-Length header is not set in the response. It follows Apache's `HttpClient` (Java), `http` (go) and .NET `HttpWebResponse` (C#) behaviors. Previously it raised a `ValueError`. + +- `addr` is now available for all addressable locations, + `unsafeAddr` is now deprecated and an alias for `addr`. + +- 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/typedthreads` + - `std/sysatomics` + + 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 the `system` module: + - Aliases with an `Error` suffix to exception types that have a `Defect` suffix + (see [exceptions](https://nim-lang.github.io/Nim/exceptions.html)): + `ArithmeticError`, `DivByZeroError`, `OverflowError`, + `AccessViolationError`, `AssertionError`, `OutOfMemError`, `IndexError`, + `FieldError`, `RangeError`, `StackOverflowError`, `ReraiseError`, + `ObjectAssignmentError`, `ObjectConversionError`, `FloatingPointError`, + `FloatOverflowError`, `FloatUnderflowError`, `FloatInexactError`, + `DeadThreadError`, `NilAccessError` + - `addQuitProc`, replaced by `exitprocs.addExitProc` + - Legacy unsigned conversion operations: `ze`, `ze64`, `toU8`, `toU16`, `toU32` + - `TaintedString`, formerly a distinct alias to `string` + - `PInt32`, `PInt64`, `PFloat32`, `PFloat64`, aliases to + `ptr int32`, `ptr int64`, `ptr float32`, `ptr float64` + +- Enabling `-d:nimPreviewSlimSystem` removes the import of `channels_builtin` in + in the `system` module, which is replaced by [threading/channels](https://github.com/nim-lang/threading/blob/master/threading/channels.nim). Use the command `nimble install threading` and import `threading/channels`. + +- Enabling `-d:nimPreviewCstringConversion` causes `ptr char`, `ptr array[N, char]` and `ptr UncheckedArray[N, char]` to not support conversion to `cstring` anymore. + +- Enabling `-d:nimPreviewProcConversion` causes `proc` to not support conversion to + `pointer` anymore. `cast` may be used instead. + +- The `gc:v2` option is removed. + +- The `mainmodule` and `m` options are removed. + +- Optional parameters in combination with `: body` syntax ([RFC #405](https://github.com/nim-lang/RFCs/issues/405)) + are now opt-in via `experimental: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 own `Math.trunc` polyfill using the [`emit` pragma](https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-emit-pragma). + Nim uses `Math.trunc` for the division and modulo operators for integers. + +- `shallowCopy` and `shallow` are removed for ARC/ORC. Use `move` when possible or combine assignment and +`sink` for optimization purposes. + +- The experimental `nimPreviewDotLikeOps` switch is going to be removed or deprecated because it didn't fulfill its promises. + +- The `{.this.}` pragma, deprecated since 0.19, has been removed. +- `nil` literals can no longer be directly assigned to variables or fields of `distinct` pointer types. They must be converted instead. + ```nim + 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.}`, and `type Foo {.final.} [T] = object`. Instead, + use `type Foo[T] {.final.} = object`. + +- `foo a = b` now means `foo(a = b)` rather than `foo(a) = b`. This is consistent + with the existing behavior of `foo a, b = c` meaning `foo(a, b = c)`. + This decision was made with the assumption that the old syntax was used rarely; + if your code used the old syntax, please be aware of this change. + +- [Overloadable enums](https://nim-lang.github.io/Nim/manual.html#overloadable-enum-value-names) and Unicode Operators + are no longer experimental. + +- `macros.getImpl` for `const` symbols now returns the full definition node + (as `nnkConstDef`) rather than the AST of the constant value. + +- Lock levels are deprecated, now a noop. + +- `strictEffects` are no longer experimental. + Use `legacy: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`. + +- Pointer to `cstring` conversions now trigger a `[PtrToCstringConv]` warning. + This warning will become an error in future versions! Use a `cast` operation + like `cast[cstring](x)` instead. + +- `logging` will default to flushing all log level messages. To get the legacy behaviour of only flushing Error and Fatal messages, use `-d:nimV1LogFlushBehavior`. + +- Redefining templates with the same signature was previously + allowed to support certain macro code. To do this explicitly, the + `{.redefine.}` pragma has been added. Note that this is only for templates. + Implicit redefinition of templates is now deprecated and will give an error in the future. + +- Using an unnamed break in a block is deprecated. This warning will become an error in future versions! Use a named block with a named break instead. + +- Several Standard libraries have been moved to nimble packages, use `nimble` to install them: + - `std/punycode` => `punycode` + - `std/asyncftpclient` => `asyncftpclient` + - `std/smtp` => `smtp` + - `std/db_common` => `db_connector/db_common` + - `std/db_sqlite` => `db_connector/db_sqlite` + - `std/db_mysql` => `db_connector/db_mysql` + - `std/db_postgres` => `db_connector/db_postgres` + - `std/db_odbc` => `db_connector/db_odbc` + - `std/md5` => `checksums/md5` + - `std/sha1` => `checksums/sha1` + - `std/sums` => `std/sums` + +- Previously, calls like `foo(a, b): ...` or `foo(a, b) do: ...` where the final argument of + `foo` had type `proc ()` were assumed by the compiler to mean `foo(a, b, proc () = ...)`. + This behavior is now deprecated. Use `foo(a, b) do (): ...` or `foo(a, b, proc () = ...)` instead. + +- When `--warning[BareExcept]:on` is enabled, if an `except` specifies no exception or any exception not inheriting from `Defect` or `CatchableError`, a `warnBareExcept` warning will be triggered. For example, the following code will emit a warning: + ```nim + try: + discard + except: # Warning: The bare except clause is deprecated; use `except CatchableError:` instead [BareExcept] + discard + ``` + +- The experimental `strictFuncs` feature now disallows a store to the heap via a `ref` or `ptr` indirection. + +- The underscore identifier (`_`) is now generally not added to scope when + used as the name of a definition. While this was already the case for + variables, it is now also the case for routine parameters, generic + parameters, routine declarations, type declarations, etc. This means that the following code now does not compile: + + ```nim + proc foo(_: int): int = _ + 1 + echo foo(1) + + proc foo[_](t: typedesc[_]): seq[_] = @[default(_)] + echo foo[int]() + + proc _() = echo "_" + _() + + type _ = int + let x: _ = 3 + ``` + + Whereas the following code now compiles: + + ```nim + proc foo(_, _: int): int = 123 + echo foo(1, 2) + + proc foo[_, _](): int = 123 + echo foo[int, bool]() + + proc foo[T, U](_: typedesc[T], _: typedesc[U]): (T, U) = (default(T), default(U)) + echo foo(int, bool) + + proc _() = echo "one" + proc _() = echo "two" + + type _ = int + type _ = float + ``` + +- Added the `--legacy:verboseTypeMismatch` switch to get legacy type mismatch error messages. + +- The JavaScript backend now uses [BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) + for 64-bit integer types (`int64` and `uint64`) by default. As this affects + JS code generation, code using these types to interface with the JS backend + may need to be updated. Note that `int` and `uint` are not affected. + + For compatibility with [platforms that do not support BigInt](https://caniuse.com/bigint) + and in the case of potential bugs with the new implementation, the + old behavior is currently still supported with the command line option + `--jsbigint64:off`. + +- The `proc` and `iterator` type classes now respectively only match + procs and iterators. Previously both type classes matched any of + procs or iterators. + + ```nim + proc prc(): int = + 123 + + iterator iter(): int {.closure.} = + yield 123 + + proc takesProc[T: proc](x: T) = discard + proc takesIter[T: iterator](x: T) = discard + + # always compiled: + takesProc(prc) + takesIter(iter) + # no longer compiles: + takesProc(iter) + takesIter(prc) + ``` + +- The `proc` and `iterator` type classes now accept a calling convention pragma + (i.e. `proc {.closure.}`) that must be shared by matching proc or iterator + types. Previously, pragmas were parsed but discarded if no parameter list + was given. + + This is represented in the AST by an `nnkProcTy`/`nnkIteratorTy` node with + an `nnkEmpty` node in the place of the `nnkFormalParams` node, and the pragma + node in the same place as in a concrete `proc` or `iterator` type node. This + state of the AST may be unexpected to existing code, both due to the + replacement of the `nnkFormalParams` node as well as having child nodes + unlike other type class AST. + +- Signed integer literals in `set` literals now default to a range type of + `0..255` instead of `0..65535` (the maximum size of sets). + +- `case` statements with `else` branches put before `elif`/`of` branches in macros + are rejected with "invalid order of case branches". + +- Destructors now default to `.raises: []` (i.e. destructors must not raise + unlisted exceptions) and explicitly raising destructors are implementation + defined behavior. + +- The very old, undocumented `deprecated` pragma statement syntax for + deprecated aliases is now a no-op. The regular deprecated pragma syntax is + generally sufficient instead. + + ```nim + # now does nothing: + {.deprecated: [OldName: NewName].} + + # instead use: + type OldName* {.deprecated: "use NewName instead".} = NewName + const oldName* {.deprecated: "use newName instead".} = newName + ``` + + `defined(nimalias)` can be used to check for versions when this syntax was + available; however since code that used this syntax is usually very old, + these deprecated aliases are likely not used anymore and it may make sense + to simply remove these statements. + +- `getProgramResult` and `setProgramResult` in `std/exitprocs` are no longer + declared when they are not available on the backend. Previously it would call + `doAssert false` at runtime despite the condition being checkable at compile-time. + +- Custom destructors now supports non-var parameters, e.g. ``proc `=destroy`[T: object](x: T)`` is valid. ``proc `=destroy`[T: object](x: var T)`` is deprecated. + +- Relative imports will not resolve to searched paths anymore, e.g. `import ./tables` now reports an error properly. + +## Standard library additions and changes + +[//]: # "Changes:" +- OpenSSL 3 is now supported. +- `macros.parseExpr` and `macros.parseStmt` now accept an optional + `filename` argument for more informative errors. +- The `colors` module is expanded with missing colors from the CSS color standard. + `colPaleVioletRed` and `colMediumPurple` have also been changed to match the CSS color standard. +- Fixed `lists.SinglyLinkedList` being broken after removing the last node ([#19353](https://github.com/nim-lang/Nim/pull/19353)). +- The `md5` module now works at compile time and in JavaScript. +- Changed `mimedb` to use an `OrderedTable` instead of `OrderedTableRef`, to support `const` tables. +- `strutils.find` now uses and defaults to `last = -1` for whole string searches, + making limiting it to just the first char (`last = 0`) valid. +- `strutils.split` and `strutils.rsplit` now return the source string as a single element for an empty separator. +- `random.rand` now works with `Ordinal`s. +- Undeprecated `os.isvalidfilename`. +- `std/oids` now uses `int64` to store time internally (before, it was int32). +- `std/uri.Uri` dollar (`$`) improved, precalculates the `string` result length from the `Uri`. +- `std/uri.Uri.isIpv6` is now exported. +- `std/logging.ConsoleLogger` and `FileLogger` now have a `flushThreshold` attribute to set what log message levels are automatically flushed. For Nim v1 use `-d:nimFlushAllLogs` to automatically flush all message levels. Flushing all logs is the default behavior for Nim v2. + + +- `std/jsfetch.newFetchOptions` now has default values for all parameters. +- `std/jsformdata` now accepts the `Blob` data type. + +- `std/sharedlist` and `std/sharedtables` are now deprecated, see [RFC #433](https://github.com/nim-lang/RFCs/issues/433). + +- There is a new compile flag (`-d:nimNoGetRandom`) when building `std/sysrand` to remove the dependency on the Linux `getrandom` syscall. + + This compile flag only affects Linux builds and is necessary if either compiling on a Linux kernel version < 3.17, or if code built will be executing on kernel < 3.17. + + On Linux kernels < 3.17 (such as kernel 3.10 in RHEL7 and CentOS7), the `getrandom` syscall was not yet introduced. Without this, the `std/sysrand` module will not build properly, and if code is built on a kernel >= 3.17 without the flag, any usage of the `std/sysrand` module will fail to execute on a kernel < 3.17 (since it attempts to perform a syscall to `getrandom`, which isn't present in the current kernel). A compile flag has been added to force the `std/sysrand` module to use /dev/urandom (available since Linux kernel 1.3.30), rather than the `getrandom` syscall. This allows for use of a cryptographically secure PRNG, regardless of kernel support for the `getrandom` syscall. + + When building for RHEL7/CentOS7 for example, the entire build process for nim from a source package would then be: + ```sh + $ yum install devtoolset-8 # Install GCC version 8 vs the standard 4.8.5 on RHEL7/CentOS7. Alternatively use -d:nimEmulateOverflowChecks. See issue #13692 for details + $ scl enable devtoolset-8 bash # Run bash shell with default toolchain of gcc 8 + $ sh build.sh # per unix install instructions + $ bin/nim c koch # per unix install instructions + $ ./koch boot -d:release # per unix install instructions + $ ./koch tools -d:nimNoGetRandom # pass the nimNoGetRandom flag to compile std/sysrand without support for getrandom syscall + ``` + + This is necessary to pass when building Nim on kernel versions < 3.17 in particular to avoid an error of "SYS_getrandom undeclared" during the build process for the stdlib (`sysrand` in particular). + +[//]: # "Additions:" +- 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 an `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 new modules which were previously part of `std/os`: + - Added `std/oserrors` for OS error reporting. + - Added `std/envvars` for environment variables handling. + - Added `std/cmdline` for reading command line parameters. + - Added `std/paths`, `std/dirs`, `std/files`, `std/symlinks` and `std/appdirs`. +- Added `sep` parameter in `std/uri` to specify the query separator. +- Added `UppercaseLetters`, `LowercaseLetters`, `PunctuationChars`, `PrintableChars` sets to `std/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`, and `matches` to `std/dom`. +- Added [`jsre.hasIndices`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/hasIndices). +- Added `capacity` for `string` and `seq` to return the current capacity, see [RFC #460](https://github.com/nim-lang/RFCs/issues/460). +- Added `openArray[char]` overloads for `std/parseutils` and `std/unicode`, allowing for more code reuse. +- Added a `safe` parameter to `base64.encodeMime`. +- Added `parseutils.parseSize` - inverse to `strutils.formatSize` - to parse human readable sizes. +- Added `minmax` to `sequtils`, as a more efficient `(min(_), max(_))` over sequences. +- `std/jscore` for the JavaScript target: + + Added bindings to [`Array.shift`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift) + and [`queueMicrotask`](https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask). + + Added `toDateString`, `toISOString`, `toJSON`, `toTimeString`, `toUTCString` converters for `DateTime`. +- Added `BackwardsIndex` overload for `CacheSeq`. +- Added support for nested `with` blocks in `std/with`. +- Added `ensureMove` to the system module. It ensures that the passed argument is moved, otherwise an error is given at the compile time. + + +[//]: # "Deprecations:" +- Deprecated `selfExe` for Nimscript. +- Deprecated `std/base64.encode` for collections of arbitrary integer element type. + Now only `byte` and `char` are supported. + +[//]: # "Removals:" +- 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` for `std/asyncjs.then` and `std/jsfetch`. +- Removed deprecated `jsre.test` and `jsre.toString`. +- Removed deprecated `math.c_frexp`. +- Removed deprecated `` httpcore.`==` ``. +- Removed deprecated `std/posix.CMSG_SPACE` and `std/posix.CMSG_LEN` that take wrong argument types. +- Removed deprecated `osproc.poDemon`, symbol with typo. +- Removed deprecated `tables.rightSize`. + + +- Removed deprecated `posix.CLONE_STOPPED`. + + +## Language changes + +- [Tag tracking](https://nim-lang.github.io/Nim/manual.html#effect-system-tag-tracking) now supports the definition of forbidden tags by the `.forbids` pragma + which can be used to disable certain effects in proc types. +- [Case statement macros](https://nim-lang.github.io/Nim/manual.html#macros-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". + +- Compile-time define changes: + - `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 backticks as in ``defined(`a.b.c`)`` to access such defines. + - [Define pragmas for constants](https://nim-lang.github.io/Nim/manual.html#implementation-specific-pragmas-compileminustime-define-pragmas) + now support a string argument for qualified define names. + + ```nim + # -d:package.FooBar=42 + const FooBar {.intdefine: "package.FooBar".}: int = 5 + echo FooBar # 42 + ``` + + This was added to help disambiguate similar define names for different packages. + In older versions, this could only be achieved with something like the following: + + ```nim + const FooBar = block: + const `package.FooBar` {.intdefine.}: int = 5 + `package.FooBar` + ``` + - A generic `define` pragma for constants has been added that interprets + the value of the define based on the type of the constant value. + See the [experimental manual](https://nim-lang.github.io/Nim/manual_experimental.html#generic-nimdefine-pragma) + for a list of supported types. + +- [Macro pragmas](https://nim-lang.github.io/Nim/manual.html#userminusdefined-pragmas-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](https://nim-lang.github.io/Nim/manual_experimental.html#extended-macro-pragmas). + - Pragma macros on type definitions can now return `nnkTypeSection` nodes as well as `nnkTypeDef`, + allowing multiple type definitions to be injected in place of the original type definition. + + ```nim + 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 + ``` + +- A new form of type inference called [top-down inference](https://nim-lang.github.io/Nim/manual_experimental.html#topminusdown-type-inference) + has been implemented for a variety of basic cases. For example, code like the following now compiles: + + ```nim + let foo: seq[(float, byte, cstring)] = @[(1, 2, "abc")] + ``` + +- `cstring` is now accepted as a selector in `case` statements, removing the + need to convert to `string`. On the JS backend, this is translated directly + to a `switch` statement. + +- Nim now supports `out` parameters and ["strict definitions"](https://nim-lang.github.io/Nim/manual_experimental.html#strict-definitions-and-nimout-parameters). +- Nim now offers a [strict mode](https://nim-lang.github.io/Nim/manual_experimental.html#strict-case-objects) for `case objects`. + +- IBM Z architecture and macOS m1 arm64 architecture are supported. + +- `=wasMoved` can now be overridden by users. + +- There is a new pragma called [quirky](https://nim-lang.github.io/Nim/manual_experimental.html#quirky-routines) that can be used to affect the code + generation of goto based exception handling. It can improve the produced code size but its effects can be subtle so use it with care. + +- Tuple unpacking for variables is now treated as syntax sugar that directly + expands into multiple assignments. Along with this, tuple unpacking for + variables can now be nested. + + ```nim + proc returnsNestedTuple(): (int, (int, int), int, int) = (4, (5, 7), 2, 3) + + let (x, (_, y), _, z) = returnsNestedTuple() + # roughly becomes + let + tmpTup1 = returnsNestedTuple() + x = tmpTup1[0] + tmpTup2 = tmpTup1[1] + y = tmpTup2[1] + z = tmpTup1[3] + ``` + + As a result `nnkVarTuple` nodes in variable sections will no longer be + reflected in `typed` AST. + +- C++ interoperability: + - New [`virtual`](https://nim-lang.github.io/Nim/manual_experimental.html#virtual-pragma) pragma added. + - Improvements to [`constructor`](https://nim-lang.github.io/Nim/manual_experimental.html#constructor-pragma) pragma. + +## Compiler changes + +- The `gc` switch has been renamed to `mm` ("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 of `NimMain` 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. +- Removed deprecated `LineTooLong` hint. +- Line numbers and file names of source files work correctly inside templates for JavaScript targets. + +- Removed support for LCC (Local C), Pelles C, Digital Mars and Watcom compilers. + + +## Docgen + +- `Markdown` is now the default markup language of doc comments (instead + of the legacy `RstMarkdown` mode). In this release we begin to separate + RST and Markdown features to better follow specification of each + language, with the focus on Markdown development. + See also [the docs](https://nim-lang.github.io/Nim/markdown_rst.html). + + * Added a `{.doctype: Markdown | RST | RstMarkdown.}` pragma allowing to + select the markup language mode in the doc comments of the current `.nim` + file for processing by `nim doc`: + + 1. `Markdown` (default) is basically CommonMark (standard Markdown) + + some Pandoc Markdown features + some RST features that are missing + in our current implementation of CommonMark and Pandoc Markdown. + 2. `RST` closely follows the RST spec with few additional Nim features. + 3. `RstMarkdown` is a maximum mix of RST and Markdown features, which + is kept for the sake of compatibility and ease of migration. + + * Added separate `md2html` and `rst2html` commands for processing + standalone `.md` and `.rst` files respectively (and also `md2tex`/`rst2tex`). + +- Added Pandoc Markdown bracket syntax `[...]` for making anchor-less links. +- Docgen now supports concise syntax for referencing Nim symbols: + instead of specifying HTML anchors directly one can use original + Nim symbol declarations (adding the aforementioned link brackets + `[...]` around them). + * To use this feature across modules, a new `importdoc` directive was added. + Using this feature for referencing also helps to ensure that links + (inside one module or the whole project) are not broken. +- Added support for RST & Markdown quote blocks (blocks starting with `>`). +- Added a popular Markdown definition lists extension. +- Added Markdown indented code blocks (blocks indented by >= 4 spaces). +- Added syntax for additional parameters to Markdown code blocks: + + ```nim test="nim c $1" + ... + ``` + +## Tool changes + +- Nim now ships Nimble version 0.14 which added support for lock-files. Libraries are stored in `$nimbleDir/pkgs2` (it was `$nimbleDir/pkgs` before). Use `nimble develop --global` to create an old style link file in the special links directory documented at https://github.com/nim-lang/nimble#nimble-develop. +- nimgrep added the option `--inContext` (and `--notInContext`), which + allows to filter only matches with the context block containing a given pattern. +- nimgrep: names of options containing "include/exclude" are deprecated, + e.g. instead of `--includeFile` and `--excludeFile` we have + `--filename` and `--notFilename` respectively. + Also the semantics are now consistent for such positive/negative filters. +- koch now supports the `--skipIntegrityCheck` option. The command `koch --skipIntegrityCheck boot -d:release` always builds the compiler twice. diff --git a/changelogs/changelog_2_2_0.md b/changelogs/changelog_2_2_0.md new file mode 100644 index 000000000..b50cbeb27 --- /dev/null +++ b/changelogs/changelog_2_2_0.md @@ -0,0 +1,248 @@ +# v2.2.0 - 2024-10-02 + + +## Changes affecting backward compatibility + +- `-d:nimStrictDelete` becomes the default. An index error is produced when the index passed to `system.delete` is out of bounds. Use `-d:nimAuditDelete` to mimic the old behavior for backward compatibility. + +- The default user-agent in `std/httpclient` has been changed to `Nim-httpclient/<version>` instead of `Nim httpclient/<version>` which was incorrect according to the HTTP spec. + +- Methods now support implementations based on a VTable by using `--experimental:vtables`. Methods are then confined to the same module where their type has been defined. + +- With `-d:nimPreviewNonVarDestructor`, non-var destructors become the default. + +- A bug where tuple unpacking assignment with a longer tuple on the RHS than the LHS was allowed has been fixed, i.e. code like: + ```nim + var a, b: int + (a, b) = (1, 2, 3, 4) + ``` + will no longer compile. + +- `internalNew` is removed from the `system` module, use `new` instead. + +- `bindMethod` in `std/jsffi` is deprecated, don't use it with closures. + +- JS backend now supports lambda lifting for closures. Use `--legacy:jsNoLambdaLifting` to emulate old behaviors. + +- JS backend now supports closure iterators. + +- `owner` in `std/macros` is deprecated. + +- Ambiguous type symbols in generic procs and templates now generate symchoice nodes. + Previously; in templates they would error immediately at the template definition, + and in generic procs a type symbol would arbitrarily be captured, losing the + information of the other symbols. This means that generic code can now give + errors for ambiguous type symbols, and macros operating on generic proc AST + may encounter symchoice nodes instead of the arbitrarily resolved type symbol nodes. + +- Partial generic instantiation of routines is no longer allowed. Previously + it compiled in niche situations due to bugs in the compiler. + + ```nim + proc foo[T, U](x: T, y: U) = echo (x, y) + proc foo[T, U](x: var T, y: U) = echo "var ", (x, y) + + proc bar[T]() = + foo[float](1, "abc") + + bar[int]() # before: (1.0, "abc"), now: type mismatch, missing generic parameter + ``` + +- `const` values now open a new scope for each constant, meaning symbols + declared in them can no longer be used outside or in the value of + other constants. + + ```nim + const foo = (var a = 1; a) + const bar = a # error + let baz = a # error + ``` + +- The following POSIX wrappers have had their types changed from signed to + unsigned types on OSX and FreeBSD/OpenBSD to correct codegen errors: + - `Gid` (was `int32`, is now `uint32`) + - `Uid` (was `int32`, is now `uint32`) + - `Dev` (was `int32`, is now `uint32` on FreeBSD) + - `Nlink` (was `int16`, is now `uint32` on OpenBSD and `uint16` on OSX/other BSD) + - `sin6_flowinfo` and `sin6_scope_id` fields of `Sockaddr_in6` + (were `int32`, are now `uint32`) + - `n_net` field of `Tnetent` (was `int32`, is now `uint32`) + +- The `Atomic[T]` type on C++ now uses C11 primitives by default instead of + `std::atomic`. To use `std::atomic` instead, `-d:nimUseCppAtomics` can be defined. + + + + + + +## Standard library additions and changes + +[//]: # "Changes:" + +- Changed `std/osfiles.copyFile` to allow specifying `bufferSize` instead of a hard-coded one. +- Changed `std/osfiles.copyFile` to use `POSIX_FADV_SEQUENTIAL` hints for kernel-level aggressive sequential read-aheads. +- `std/htmlparser` has been moved to a nimble package, use `nimble` or `atlas` to install it. +- Changed `std/os.copyDir` and `copyDirWithPermissions` to allow skipping special "file" objects like FIFOs, device files, etc on Unix by specifying a `skipSpecial` parameter. + +[//]: # "Additions:" + +- Added `newStringUninit` to the `system` module, which creates a new string of length `len` like `newString` but with uninitialized content. +- Added `setLenUninit` to the `system` module, which doesn't initialize +slots when enlarging a sequence. +- Added `hasDefaultValue` to `std/typetraits` to check if a type has a valid default value. +- Added `rangeBase` to `std/typetraits` to obtain the base type of a range type or + convert a value with a range type to its base type. +- Added Viewport API for the JavaScript targets in the `dom` module. +- Added `toSinglyLinkedRing` and `toDoublyLinkedRing` to `std/lists` to convert from `openArray`s. +- ORC: To be enabled via `nimOrcStats` there is a new API called `GC_orcStats` that can be used to query how many + objects the cyclic collector did free. If the number is zero that is a strong indicator that you can use `--mm:arc` + instead of `--mm:orc`. +- A `$` template is provided for `Path` in `std/paths`. +- `std/hashes.hash(x:string)` changed to produce a 64-bit string `Hash` (based +on Google's Farm Hash) which is also often faster than the present one. Define +`nimStringHash2` to get the old values back. `--jsbigint=off` mode always only +produces the old values. This may impact your automated tests if they depend +on hash order in some obvious or indirect way. Using `sorted` or `OrderedTable` +is often an easy workaround. + +[//]: # "Deprecations:" + +- Deprecates `system.newSeqUninitialized`, which is replaced by `newSeqUninit`. + +[//]: # "Removals:" + + + + + + +## Language changes + +- `noInit` can be used in types and fields to disable member initializers in the C++ backend. + +- C++ custom constructors initializers see https://nim-lang.org/docs/manual_experimental.html#constructor-initializer + +- `member` can be used to attach a procedure to a C++ type. + +- C++ `constructor` now reuses `result` instead creating `this`. + +- Tuple unpacking changes: + - Tuple unpacking assignment now supports using underscores to discard values. + ```nim + var a, c: int + (a, _, c) = (1, 2, 3) + ``` + - Tuple unpacking variable declarations now support type annotations, but + only for the entire tuple. + ```nim + let (a, b): (int, int) = (1, 2) + let (a, (b, c)): (byte, (float, cstring)) = (1, (2, "abc")) + ``` + +- The experimental option `--experimental:openSym` has been added to allow + captured symbols in generic routine and template bodies respectively to be + replaced by symbols injected locally by templates/macros at instantiation + time. `bind` may be used to keep the captured symbols over the injected ones + regardless of enabling the option, but other methods like renaming the + captured symbols should be used instead so that the code is not affected by + context changes. + + Since this change may affect runtime behavior, the experimental switch + `openSym` needs to be enabled; and a warning is given in the case where an + injected symbol would replace a captured symbol not bound by `bind` and + the experimental switch isn't enabled. + + ```nim + const value = "captured" + template foo(x: int, body: untyped): untyped = + let value {.inject.} = "injected" + body + + proc old[T](): string = + foo(123): + return value # warning: a new `value` has been injected, use `bind` or turn on `experimental:openSym` + echo old[int]() # "captured" + + template oldTempl(): string = + block: + foo(123): + value # warning: a new `value` has been injected, use `bind` or turn on `experimental:openSym` + echo oldTempl() # "captured" + + {.experimental: "openSym".} + + proc bar[T](): string = + foo(123): + return value + assert bar[int]() == "injected" # previously it would be "captured" + + proc baz[T](): string = + bind value + foo(123): + return value + assert baz[int]() == "captured" + + template barTempl(): string = + block: + foo(123): + value + assert barTempl() == "injected" # previously it would be "captured" + + template bazTempl(): string = + bind value + block: + foo(123): + value + assert bazTempl() == "captured" + ``` + + This option also generates a new node kind `nnkOpenSym` which contains + exactly 1 `nnkSym` node. In the future this might be merged with a slightly + modified `nnkOpenSymChoice` node but macros that want to support the + experimental feature should still handle `nnkOpenSym`, as the node kind would + simply not be generated as opposed to being removed. + + Another experimental switch `genericsOpenSym` exists that enables this behavior + at instantiation time, meaning templates etc can enable it specifically when + they are being called. However this does not generate `nnkOpenSym` nodes + (unless the other switch is enabled) and so doesn't reflect the regular + behavior of the switch. + + ```nim + const value = "captured" + template foo(x: int, body: untyped): untyped = + let value {.inject.} = "injected" + {.push experimental: "genericsOpenSym".} + body + {.pop.} + + proc bar[T](): string = + foo(123): + return value + echo bar[int]() # "injected" + + template barTempl(): string = + block: + var res: string + foo(123): + res = value + res + assert barTempl() == "injected" + ``` + + + + + +## Compiler changes + +- `--nimcache` using a relative path as the argument in a config file is now relative to the config file instead of the current directory. + + + + + +## Tool changes + +- koch now allows bootstrapping with `-d:nimHasLibFFI`, replacing the older option of building the compiler directly w/ the `libffi` nimble package. diff --git a/changelogs/changelog_X_XX_X.md b/changelogs/changelog_X_XX_X.md index 48520fd44..f8a09a535 100644 --- a/changelogs/changelog_X_XX_X.md +++ b/changelogs/changelog_X_XX_X.md @@ -1,14 +1,17 @@ -# v1.xx.x - yyyy-mm-dd +# v2.xx.x - yyyy-mm-dd This is an example file. The changes should go to changelog.md! +## Changes affecting backward compatibility + +- `foo` now behaves differently, use `-d:nimLegacyFoo` for previous behavior. ## Standard library additions and changes - Added `example.exampleProc`. -- Changed `example.foo` to take additional `bar` parameter. +- Changed `example.foo` to take additional `bar` parameter. ## Language changes |