diff options
Diffstat (limited to 'changelogs')
-rw-r--r-- | changelogs/changelog_0_18_1.md | 663 | ||||
-rw-r--r-- | changelogs/changelog_0_19_0.md | 253 | ||||
-rw-r--r-- | changelogs/changelog_0_20_0.md | 294 | ||||
-rw-r--r-- | changelogs/changelog_0_20_2.md | 55 | ||||
-rw-r--r-- | changelogs/changelog_1_0_0.md | 138 | ||||
-rw-r--r-- | changelogs/changelog_1_0_2.md | 56 | ||||
-rw-r--r-- | changelogs/changelog_1_2_0.md | 535 | ||||
-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 | 23 | ||||
-rw-r--r-- | changelogs/readme.md | 61 |
14 files changed, 5047 insertions, 0 deletions
diff --git a/changelogs/changelog_0_18_1.md b/changelogs/changelog_0_18_1.md new file mode 100644 index 000000000..d0b7fd8ee --- /dev/null +++ b/changelogs/changelog_0_18_1.md @@ -0,0 +1,663 @@ +## v0.18.0 - 01/03/2018 + +### Changes affecting backwards compatibility + +#### Breaking changes in the standard library + +- The ``[]`` proc for strings now raises an ``IndexError`` exception when + the specified slice is out of bounds. See issue + [#6223](https://github.com/nim-lang/Nim/issues/6223) for more details. + You can use ``substr(str, start, finish)`` to get the old behaviour back, + see [this commit](https://github.com/nim-lang/nimbot/commit/98cc031a27ea89947daa7f0bb536bcf86462941f) for an example. + +- ``strutils.split`` and ``strutils.rsplit`` with an empty string and a + separator now returns that empty string. + See issue [#4377](https://github.com/nim-lang/Nim/issues/4377). + +- Arrays of char cannot be converted to ``cstring`` anymore, pointers to + arrays of char can! This means ``$`` for arrays can finally exist + in ``system.nim`` and do the right thing. This means ``$myArrayOfChar`` changed + its behaviour! Compile with ``-d:nimNoArrayToString`` to see where to fix your + code. + +- `reExtended` is no longer default for the `re` constructor in the `re` + module. + +- The behavior of ``$`` has been changed for all standard library collections. The + collection-to-string implementations now perform proper quoting and escaping of + strings and chars. + +- `newAsyncSocket` taking an `AsyncFD` now runs `setBlocking(false)` on the + fd. + +- ``mod`` and bitwise ``and`` do not produce ``range`` subtypes anymore. This + turned out to be more harmful than helpful and the language is simpler + without this special typing rule. + +- ``formatFloat``/``formatBiggestFloat`` now support formatting floats with zero + precision digits. The previous ``precision = 0`` behavior (default formatting) + is now available via ``precision = -1``. + +- Moved from stdlib into Nimble packages: + - [``basic2d``](https://github.com/nim-lang/basic2d) + _deprecated: use ``glm``, ``arraymancer``, ``neo``, or another package instead_ + - [``basic3d``](https://github.com/nim-lang/basic3d) + _deprecated: use ``glm``, ``arraymancer``, ``neo``, or another package instead_ + - [``gentabs``](https://github.com/lcrees/gentabs) + - [``libuv``](https://github.com/lcrees/libuv) + - [``numeric``](https://github.com/lcrees/polynumeric) + - [``poly``](https://github.com/lcrees/polynumeric) + - [``pdcurses``](https://github.com/lcrees/pdcurses) + - [``romans``](https://github.com/lcrees/romans) + - [``libsvm``](https://github.com/nim-lang/libsvm_legacy) + - [``joyent_http_parser``](https://github.com/nim-lang/joyent_http_parser) + +- Proc [toCountTable](https://nim-lang.org/docs/tables.html#toCountTable,openArray[A]) + now produces a `CountTable` with values correspoding to the number of occurrences + of the key in the input. It used to produce a table with all values set to `1`. + + Counting occurrences in a sequence used to be: + + ```nim + let mySeq = @[1, 2, 1, 3, 1, 4] + var myCounter = initCountTable[int]() + + for item in mySeq: + myCounter.inc item + ``` + + Now, you can simply do: + + ```nim + let + mySeq = @[1, 2, 1, 3, 1, 4] + myCounter = mySeq.toCountTable() + ``` + +- If you use ``--dynlibOverride:ssl`` with OpenSSL 1.0.x, you now have to + define ``openssl10`` symbol (``-d:openssl10``). By default OpenSSL 1.1.x is + assumed. + +- ``newNativeSocket`` is now named ``createNativeSocket``. + +- ``newAsyncNativeSocket`` is now named ``createAsyncNativeSocket`` + and it no longer raises an OS error but returns an ``osInvalidSocket`` when + creation fails. + +- The ``securehash`` module is now deprecated. Instead import ``std / sha1``. + +- The ``readPasswordFromStdin`` proc has been moved from the ``rdstdin`` + to the ``terminal`` module, thus it does not depend on linenoise anymore. + +#### Breaking changes in the compiler + +- ``\n`` is now only the single line feed character like in most + other programming languages. The new platform specific newline escape sequence is + written as ``\p``. This change only affects the Windows platform. + +- The overloading rules changed slightly so that constrained generics are + preferred over unconstrained generics. (Bug #6526) + +- We changed how array accesses "from backwards" like ``a[^1]`` or ``a[0..^1]`` are + implemented. These are now implemented purely in ``system.nim`` without compiler + support. There is a new "heterogeneous" slice type ``system.HSlice`` that takes 2 + generic parameters which can be ``BackwardsIndex`` indices. ``BackwardsIndex`` is + produced by ``system.^``. + This means if you overload ``[]`` or ``[]=`` you need to ensure they also work + with ``system.BackwardsIndex`` (if applicable for the accessors). + +- The parsing rules of ``if`` expressions were changed so that multiple + statements are allowed in the branches. We found few code examples that + now fail because of this change, but here is one: + +```nim +t[ti] = if exp_negative: '-' else: '+'; inc(ti) +``` + +This now needs to be written as: + +```nim +t[ti] = (if exp_negative: '-' else: '+'); inc(ti) +``` + +- The experimental overloading of the dot ``.`` operators now take + an ``untyped``` parameter as the field name, it used to be + a ``static[string]``. You can use ``when defined(nimNewDot)`` to make + your code work with both old and new Nim versions. + See [special-operators](https://nim-lang.org/docs/manual.html#special-operators) + for more information. + +- ``yield`` (or ``await`` which is mapped to ``yield``) never worked reliably + in an array, seq or object constructor and is now prevented at compile-time. + +### Library additions + +- **Added ``sequtils.mapLiterals`` for easier construction of array and tuple literals.** + +- Added ``system.runnableExamples`` to make examples in Nim's documentation easier + to write and test. The examples are tested as the last step of + ``nim doc``. + +- Implemented ``getIoHandler`` proc in the ``asyncdispatch`` module that allows + you to retrieve the underlying IO Completion Port or ``Selector[AsyncData]`` + object in the specified dispatcher. + +- For string formatting / interpolation a new module + called [strformat](https://nim-lang.org/docs/strformat.html) has been added + to the stdlib. + +- The `ReadyKey` type in the selectors module now contains an ``errorCode`` + field to help distinguish between ``Event.Error`` events. + +- Implemented an `accept` proc that works on a `SocketHandle` in + ``nativesockets``. + +- Added ``algorithm.rotateLeft``. + +- Added ``typetraits.$`` as an alias for ``typetraits.name``. + +- Added ``system.getStackTraceEntries`` that allows you to access the stack + trace in a structured manner without string parsing. + +- Added ``parseutils.parseSaturatedNatural``. + +- Added ``macros.unpackVarargs``. + +- Added support for asynchronous programming for the JavaScript backend using + the `asyncjs` module. + +- Added true color support for some terminals. Example: +```nim +import colors, terminal + +const Nim = "Efficient and expressive programming." + +var + fg = colYellow + bg = colBlue + int = 1.0 + +enableTrueColors() + +for i in 1..15: + styledEcho bgColor, bg, fgColor, fg, Nim, resetStyle + int -= 0.01 + fg = intensity(fg, int) + +setForegroundColor colRed +setBackgroundColor colGreen +styledEcho "Red on Green.", resetStyle +``` + +### Library changes + +- ``echo`` now works with strings that contain ``\0`` (the binary zero is not + shown) and ``nil`` strings are equal to empty strings. + +- JSON: Deprecated `getBVal`, `getFNum`, and `getNum` in favour of + `getBool`, `getFloat`, `getBiggestInt`. A new `getInt` procedure was also + added. + +- ``rationals.toRational`` now uses an algorithm based on continued fractions. + This means its results are more precise and it can't run into an infinite loop + anymore. + +- ``os.getEnv`` now takes an optional ``default`` parameter that tells ``getEnv`` + what to return if the environment variable does not exist. + +- The ``random`` procs in ``random.nim`` have all been deprecated. Instead use + the new ``rand`` procs. The module now exports the state of the random + number generator as type ``Rand`` so multiple threads can easily use their + own random number generators that do not require locking. For more information + about this rename see issue [#6934](https://github.com/nim-lang/Nim/issues/6934) + +- ``writeStackTrace`` is now proclaimed to have no IO effect (even though it does) + so that it is more useful for debugging purposes. + +- ``db_mysql`` module: ``DbConn`` is now a ``distinct`` type that doesn't expose the + details of the underlying ``PMySQL`` type. + +- ``parseopt2`` is now deprecated, use ``parseopt`` instead. + +### Language additions + +- It is now possible to forward declare object types so that mutually + recursive types can be created across module boundaries. See + [package level objects](https://nim-lang.org/docs/manual.html#package-level-objects) + for more information. + +- Added support for casting between integers of same bitsize in VM (compile time and nimscript). + This allows to, among other things, reinterpret signed integers as unsigned. + +- Custom pragmas are now supported using pragma ``pragma``, please see language + manual for details. + +- Standard library modules can now also be imported via the ``std`` pseudo-directory. + This is useful in order to distinguish between standard library and nimble package + imports: + + ```nim + import std / [strutils, os, osproc] + import someNimblePackage / [strutils, os] + ``` + +### Language changes + +- The **unary** ``<`` is now deprecated, for ``.. <`` use ``..<`` for other usages + use the ``pred`` proc. + +- Bodies of ``for`` loops now get their own scope: + +```nim +# now compiles: +for i in 0..4: + let i = i + 1 + echo i +``` + +- To make Nim even more robust the system iterators ``..`` and ``countup`` + now only accept a single generic type ``T``. This means the following code + doesn't die with an "out of range" error anymore: + +```nim +var b = 5.Natural +var a = -5 +for i in a..b: + echo i +``` + +- ``atomic`` and ``generic`` are no longer keywords in Nim. ``generic`` used to be + an alias for ``concept``, ``atomic`` was not used for anything. + +- The memory manager now uses a variant of the TLSF algorithm that has much + better memory fragmentation behaviour. According + to [http://www.gii.upv.es/tlsf/](http://www.gii.upv.es/tlsf/) the maximum + fragmentation measured is lower than 25%. As a nice bonus ``alloc`` and + ``dealloc`` became O(1) operations. + +- The compiler is now more consistent in its treatment of ambiguous symbols: + Types that shadow procs and vice versa are marked as ambiguous (bug #6693). + +- codegenDecl pragma now works for the JavaScript backend. It returns an empty + string for function return type placeholders. + +- Extra semantic checks for procs with noreturn pragma: return type is not allowed, + statements after call to noreturn procs are no longer allowed. + +- Noreturn proc calls and raising exceptions branches are now skipped during common type + deduction in ``if`` and ``case`` expressions. The following code snippets now compile: + ```nim + import strutils + let str = "Y" + let a = case str: + of "Y": true + of "N": false + else: raise newException(ValueError, "Invalid boolean") + let b = case str: + of nil, "": raise newException(ValueError, "Invalid boolean") + elif str.startsWith("Y"): true + elif str.startsWith("N"): false + else: false + let c = if str == "Y": true + elif str == "N": false + else: + echo "invalid bool" + quit("this is the end") + ``` + +- Pragmas now support call syntax, for example: ``{.exportc"myname".}`` and + ``{.exportc("myname").}`` + +- The ``deprecated`` pragma now supports a user-definable warning message for procs. + + ```nim + proc bar {.deprecated: "use foo instead".} = + return + + bar() + ``` + +### Tool changes + +- The ``nim doc`` command is now an alias for ``nim doc2``, the second version of + the documentation generator. The old version 1 can still be accessed + via the new ``nim doc0`` command. + +- Nim's ``rst2html`` command now supports the testing of code snippets via an RST + extension that we called ``:test:``:: + + ```rst + .. code-block:: nim + :test: + # shows how the 'if' statement works + if true: echo "yes" + ``` + +### Compiler changes + +### Bugfixes + +- Fixed "ReraiseError when using try/except within finally block" + ([#5871](https://github.com/nim-lang/Nim/issues/5871)) +- Fixed "Range type inference leads to counter-intuitive behvaiour" + ([#5854](https://github.com/nim-lang/Nim/issues/5854)) +- Fixed "JSON % operator can fail in extern procs with dynamic types" + ([#6385](https://github.com/nim-lang/Nim/issues/6385)) +- Fixed ""intVal is not accessible" in VM" + ([#6083](https://github.com/nim-lang/Nim/issues/6083)) +- Fixed "Add excl for OrderedSet" + ([#2467](https://github.com/nim-lang/Nim/issues/2467)) +- Fixed "newSeqOfCap actually doesn't reserve memory" + ([#6403](https://github.com/nim-lang/Nim/issues/6403)) +- Fixed "[Regression] Nim segfaults" + ([#6435](https://github.com/nim-lang/Nim/issues/6435)) +- Fixed "Seq assignment is slower than expected" + ([#6433](https://github.com/nim-lang/Nim/issues/6433)) +- Fixed "json module issues with empty dicts and lists" + ([#6438](https://github.com/nim-lang/Nim/issues/6438)) +- Fixed "mingw installed via finish.exe fails to link if Nim located in path with whitespace" + ([#6452](https://github.com/nim-lang/Nim/issues/6452)) +- Fixed "unittest.check does not perform short-circuit evaluation" + ([#5784](https://github.com/nim-lang/Nim/issues/5784)) +- Fixed "Error while concatenating an array of chars." + ([#5861](https://github.com/nim-lang/Nim/issues/5861)) +- Fixed "range initialization: [ProveInit] hint: Cannot prove that" + ([#6474](https://github.com/nim-lang/Nim/issues/6474)) +- Fixed "scanf can call procs with side-effects multiple times" + ([#6487](https://github.com/nim-lang/Nim/issues/6487)) +- Fixed "gcsafe detection problem" + ([#5620](https://github.com/nim-lang/Nim/issues/5620)) +- Fixed "C++ codegen: `mitems` generates invalid code." + ([#4910](https://github.com/nim-lang/Nim/issues/4910)) +- Fixed "strange runtime behavior on macOS" + ([#6496](https://github.com/nim-lang/Nim/issues/6496)) +- Fixed "stdtmpl: invalid indentation after a line ending in question mark" + ([#5070](https://github.com/nim-lang/Nim/issues/5070)) +- Fixed "Windows: NAN troubles on c backend" + ([#6511](https://github.com/nim-lang/Nim/issues/6511)) +- Fixed "lib/nim/system/cellsets.nim(33, 31) Error: type mismatch while attempting to compile for 16bit CPUs" + ([#3558](https://github.com/nim-lang/Nim/issues/3558)) +- Fixed "Can't compile dynlib with ``-d:useNimRtl`` and ``--threads:on``" + ([#5143](https://github.com/nim-lang/Nim/issues/5143)) +- Fixed "var s = @[0,1,2,...] can generate thousand of single assignments in C code" + ([#5007](https://github.com/nim-lang/Nim/issues/5007)) +- Fixed "`echo` discards everything after a null character" + ([#1137](https://github.com/nim-lang/Nim/issues/1137)) +- Fixed "Turn off reExtended by default" + ([#5627](https://github.com/nim-lang/Nim/issues/5627)) +- Fixed "Bad Links in docs/backends.html" + ([#5914](https://github.com/nim-lang/Nim/issues/5914)) +- Fixed "Index out of bounds error in db_postgres when executing non parameter-substituted queries containing "?"" + ([#6571](https://github.com/nim-lang/Nim/issues/6571)) +- Fixed "Please add pipe2 support to posix stdlib" + ([#6553](https://github.com/nim-lang/Nim/issues/6553)) +- Fixed "Return semantics vary depending on return style" + ([#6422](https://github.com/nim-lang/Nim/issues/6422)) +- Fixed "parsecsv.open reports SIGSEGV when calling 'open' on missing file" + ([#6148](https://github.com/nim-lang/Nim/issues/6148)) +- Fixed "VCC: Nim generates non-compilable code for system.nim" + ([#6606](https://github.com/nim-lang/Nim/issues/6606)) +- Fixed "Generic subtype matches worse than a generic" + ([#6526](https://github.com/nim-lang/Nim/issues/6526)) +- Fixed "formatFloat inconsistent scientific notation" + ([#6589](https://github.com/nim-lang/Nim/issues/6589)) +- Fixed "Generated c code calls function twice" + ([#6292](https://github.com/nim-lang/Nim/issues/6292)) +- Fixed "Range type inference leads to counter-intuitive behvaiour" + ([#5854](https://github.com/nim-lang/Nim/issues/5854)) +- Fixed "New backward indexing is too limited" + ([#6631](https://github.com/nim-lang/Nim/issues/6631)) +- Fixed "Table usage in a macro (SIGSEGV: Illegal storage access.)" + ([#1860](https://github.com/nim-lang/Nim/issues/1860)) +- Fixed "Incorrect deprecation error" + ([#6634](https://github.com/nim-lang/Nim/issues/6634)) +- Fixed "Wrong indices in arrays not starting with 0" + ([#6675](https://github.com/nim-lang/Nim/issues/6675)) +- Fixed "if expressions" + ([#6609](https://github.com/nim-lang/Nim/issues/6609)) +- Fixed "BackwardsIndex: converter + `[]` + unrelated type[^1]: lib/system.nim(3536, 3) Error" + ([#6692](https://github.com/nim-lang/Nim/issues/6692)) +- Fixed "BackwardsIndex: converter + `[]` + unrelated type[^1]: lib/system.nim(3536, 3) Error" + ([#6692](https://github.com/nim-lang/Nim/issues/6692)) +- Fixed "js backend 0.17.3: array bounds check for non zero based arrays is buggy" + ([#6532](https://github.com/nim-lang/Nim/issues/6532)) +- Fixed "HttpClient's new API doesn't work through a proxy for https URLs" + ([#6685](https://github.com/nim-lang/Nim/issues/6685)) +- Fixed "isServing isn't declared and isn't compiling" + ([#6707](https://github.com/nim-lang/Nim/issues/6707)) +- Fixed "[Regression] value out of range" + ([#6710](https://github.com/nim-lang/Nim/issues/6710)) + +- Fixed "Error when using `multisync` macro" + ([#6708](https://github.com/nim-lang/Nim/issues/6708)) + +- Fixed "formatFloat inconsistent scientific notation" + ([#6589](https://github.com/nim-lang/Nim/issues/6589)) +- Fixed "Using : (constructor arguments) for passing values to functions with default arguments causes a compiler crash." + ([#6765](https://github.com/nim-lang/Nim/issues/6765)) +- Fixed "In-place object initialization leads to vcc incompatible code" + ([#6757](https://github.com/nim-lang/Nim/issues/6757)) +- Fixed "Improve parseCookies doc" + ([#5721](https://github.com/nim-lang/Nim/issues/5721)) +- Fixed "Parser regression with nested do notation inside conditional" + ([#6166](https://github.com/nim-lang/Nim/issues/6166)) +- Fixed "Request for better error message" + ([#6776](https://github.com/nim-lang/Nim/issues/6776)) +- Fixed "Testament tester does not execute test with `exitcode` only" + ([#6775](https://github.com/nim-lang/Nim/issues/6775)) +- Fixed "JS integer division off by one" + ([#6753](https://github.com/nim-lang/Nim/issues/6753)) +- Fixed "Regression: cannot prove not nil" + ([#5781](https://github.com/nim-lang/Nim/issues/5781)) +- Fixed "SIGSEGV: Illegal storage access. (Attempt to read from nil?) in generic proc" + ([#6073](https://github.com/nim-lang/Nim/issues/6073)) +- Fixed "Request for better error message" + ([#6776](https://github.com/nim-lang/Nim/issues/6776)) +- Fixed "Nim #head: sorting via reference hangs compiler" + ([#6724](https://github.com/nim-lang/Nim/issues/6724)) +- Fixed "Cannot cast pointer to char in cpp" + ([#5979](https://github.com/nim-lang/Nim/issues/5979)) +- Fixed "asynchttpserver replies with several errors on single request" + ([#6386](https://github.com/nim-lang/Nim/issues/6386)) +- Fixed "object variants superclass trigger bad codegen" + ([#5521](https://github.com/nim-lang/Nim/issues/5521)) +- Fixed "JS integer division off by one" + ([#6753](https://github.com/nim-lang/Nim/issues/6753)) +- Fixed "js backend compiler crash with tables indexed by certain types" + ([#6568](https://github.com/nim-lang/Nim/issues/6568)) +- Fixed "Jsgen bug with is" + ([#6445](https://github.com/nim-lang/Nim/issues/6445)) +- Fixed "Subrange definition with ..<" + ([#6788](https://github.com/nim-lang/Nim/issues/6788)) +- Fixed "fields not initialized: array with enum index type as object field." + ([#6682](https://github.com/nim-lang/Nim/issues/6682)) +- Fixed "Can not delete data in table when table's data type is kind of "not nil"" + ([#6555](https://github.com/nim-lang/Nim/issues/6555)) +- Fixed "tables.nim: Cannot prove that 'n' is initialized" + ([#6121](https://github.com/nim-lang/Nim/issues/6121)) +- Fixed "issues with 'not nil' applied to a closure proc" + ([#6489](https://github.com/nim-lang/Nim/issues/6489)) +- Fixed "`not nil` not working in some cases" + ([#4686](https://github.com/nim-lang/Nim/issues/4686)) +- Fixed "Cannot prove '@[v]' is not nil" + ([#3993](https://github.com/nim-lang/Nim/issues/3993)) + +- Fixed "Feature: support TCP_NODELAY in net.sockets" + ([#6795](https://github.com/nim-lang/Nim/issues/6795)) +- Fixed "Code that makes the compiler throw an error message and then hangs" + ([#6820](https://github.com/nim-lang/Nim/issues/6820)) +- Fixed "Code that makes the compiler throw an error message and then hangs" + ([#6820](https://github.com/nim-lang/Nim/issues/6820)) +- Fixed "Inconsistent behavior with sequence and string slicing" + ([#6223](https://github.com/nim-lang/Nim/issues/6223)) +- Fixed "Wrong behavior of "split" (proc and iterator)" + ([#4377](https://github.com/nim-lang/Nim/issues/4377)) +- Fixed "[Documentation] Invalid module name: [foo, bar]" + ([#6831](https://github.com/nim-lang/Nim/issues/6831)) +- Fixed "The destructor is not called for temporary objects" + ([#4214](https://github.com/nim-lang/Nim/issues/4214)) +- Fixed "Destructors does not work with implicit items iterator in for loop" + ([#985](https://github.com/nim-lang/Nim/issues/985)) +- Fixed "Error in template when using the type of the parameter inside it" + ([#6756](https://github.com/nim-lang/Nim/issues/6756)) +- Fixed "should json.to() respect parent attributes?" + ([#5856](https://github.com/nim-lang/Nim/issues/5856)) +- Fixed "json 'to' macro can not marshalize into tuples" + ([#6095](https://github.com/nim-lang/Nim/issues/6095)) +- Fixed "json.to fails with seq[T]" + ([#6604](https://github.com/nim-lang/Nim/issues/6604)) +- Fixed "json.to() is not worth using compared to marshal.to[T]" + ([#5848](https://github.com/nim-lang/Nim/issues/5848)) +- Fixed "Memory not being released in time, running out of memory" + ([#6031](https://github.com/nim-lang/Nim/issues/6031)) +- Fixed "[Regression] Bad C codegen for generic code" + ([#6889](https://github.com/nim-lang/Nim/issues/6889)) +- Fixed "rollingFileLogger deletes file on every start." + ([#6264](https://github.com/nim-lang/Nim/issues/6264)) +- Fixed "Remove/deprecate securehash module." + ([#6033](https://github.com/nim-lang/Nim/issues/6033)) +- Fixed "[bug or not] object construction for seq[T] failed without space after colon" + ([#5999](https://github.com/nim-lang/Nim/issues/5999)) +- Fixed "issues with the random module" + ([#4726](https://github.com/nim-lang/Nim/issues/4726)) +- Fixed "Reassigning local var to seq of objects results in nil element in Object's seq field" + ([#668](https://github.com/nim-lang/Nim/issues/668)) +- Fixed "Compilation error with "newseq[string]"" + ([#6726](https://github.com/nim-lang/Nim/issues/6726)) +- Fixed "await inside array/dict literal produces invalid code - Part 2" + ([#6626](https://github.com/nim-lang/Nim/issues/6626)) +- Fixed "terminal.eraseline() gives OverflowError on Windows" + ([#6931](https://github.com/nim-lang/Nim/issues/6931)) +- Fixed "[Regression] `sequtils.any` conflicts with `system.any`" + ([#6932](https://github.com/nim-lang/Nim/issues/6932)) +- Fixed "C++ codegen: `mitems` generates invalid code." + ([#4910](https://github.com/nim-lang/Nim/issues/4910)) +- Fixed "seq.mitems produces invalid cpp codegen" + ([#6892](https://github.com/nim-lang/Nim/issues/6892)) +- Fixed "Concepts regression" + ([#6108](https://github.com/nim-lang/Nim/issues/6108)) +- Fixed "Generic iterable concept with array crashes compiler" + ([#6277](https://github.com/nim-lang/Nim/issues/6277)) +- Fixed "C code generation "‘a’ is a pointer; did you mean to use ‘->’?"" + ([#6462](https://github.com/nim-lang/Nim/issues/6462)) +- Fixed "`--NimblePath` fails if a `-` in path which is not followed by a number" + ([#6949](https://github.com/nim-lang/Nim/issues/6949)) +- Fixed ""not registered in the selector" in asyncfile.close() for something that clearly was registered" + ([#6906](https://github.com/nim-lang/Nim/issues/6906)) +- Fixed "strange frexp behavior" + ([#6353](https://github.com/nim-lang/Nim/issues/6353)) + +- Fixed "noreturn branches of case statements shouldn't contribute to type" + ([#6885](https://github.com/nim-lang/Nim/issues/6885)) +- Fixed "Type inference for 'if' statements changed" + ([#6980](https://github.com/nim-lang/Nim/issues/6980)) +- Fixed "newest asyncdispatch recursion" + ([#6100](https://github.com/nim-lang/Nim/issues/6100)) +- Fixed "Ambiguous identifier between set type and proc" + ([#6965](https://github.com/nim-lang/Nim/issues/6965)) + +- Fixed "Inconsistent behavior with sequence and string slicing" + ([#6223](https://github.com/nim-lang/Nim/issues/6223)) + +- Fixed "Unsupported OpenSSL library imported dynamically" + ([#5000](https://github.com/nim-lang/Nim/issues/5000)) +- Fixed "`nim check` segfaults" + ([#6972](https://github.com/nim-lang/Nim/issues/6972)) +- Fixed "GC deadlock" + ([#6988](https://github.com/nim-lang/Nim/issues/6988)) +- Fixed "Create a seq without memory initialization" + ([#6401](https://github.com/nim-lang/Nim/issues/6401)) +- Fixed "Fix bug for getch on Windows while using the arrow keys" + ([#6966](https://github.com/nim-lang/Nim/issues/6966)) +- Fixed "runnableExamples doesn't work in templates" + ([#7018](https://github.com/nim-lang/Nim/issues/7018)) +- Fixed "runnableExamples doesn't work with untyped statement blocks" + ([#7019](https://github.com/nim-lang/Nim/issues/7019)) + +- Fixed "Critical bug in parseBiggestFloat" + ([#7060](https://github.com/nim-lang/Nim/issues/7060)) +- Fixed "[RFC] strformat.% should be gone" + ([#7078](https://github.com/nim-lang/Nim/issues/7078)) +- Fixed "compiler crash on simple macro" + ([#7093](https://github.com/nim-lang/Nim/issues/7093)) +- Fixed "Make newlines sane again" + ([#7089](https://github.com/nim-lang/Nim/issues/7089)) +- Fixed "JS - Unicode enum string representation issue" + ([#6741](https://github.com/nim-lang/Nim/issues/6741)) +- Fixed "Strange behaviour of 0.17.3 (working ok in 0.17.2)" + ([#6989](https://github.com/nim-lang/Nim/issues/6989)) +- Fixed "Strange behaviour of 0.17.3 (working ok in 0.17.2)" + ([#6989](https://github.com/nim-lang/Nim/issues/6989)) +- Fixed "Compiler crash: try expression with infix as" + ([#7116](https://github.com/nim-lang/Nim/issues/7116)) +- Fixed "nimsuggest crash" + ([#7140](https://github.com/nim-lang/Nim/issues/7140)) +- Fixed "[RFC] Reintroduce readChar" + ([#7072](https://github.com/nim-lang/Nim/issues/7072)) +- Fixed "Copyright line needs updating" + ([#7129](https://github.com/nim-lang/Nim/issues/7129)) +- Fixed "-0.0 doesn't result in negative zero in VM" + ([#7079](https://github.com/nim-lang/Nim/issues/7079)) +- Fixed "Windows large filesize" + ([#7121](https://github.com/nim-lang/Nim/issues/7121)) +- Fixed "Securehash is not parsimonious with MD5 and other hash modules" + ([#6961](https://github.com/nim-lang/Nim/issues/6961)) +- Fixed "os.findExe() shouldn't look in current directory on posix, unless exe has a /" + ([#6939](https://github.com/nim-lang/Nim/issues/6939)) +- Fixed "`compiles(...)` with `fatal` pragma causes compiler to exit early" + ([#7080](https://github.com/nim-lang/Nim/issues/7080)) +- Fixed "NPE when compile macro that returns concrete value" + ([#5450](https://github.com/nim-lang/Nim/issues/5450)) +- Fixed "Using a variable of type `int | float` causes internal compiler error" + ([#6946](https://github.com/nim-lang/Nim/issues/6946)) +- Fixed "Unsigned integers could not be used as array indexes." + ([#7153](https://github.com/nim-lang/Nim/issues/7153)) +- Fixed "countdown with uint causes underflow" + ([#4220](https://github.com/nim-lang/Nim/issues/4220)) +- Fixed "Inconsistent method call syntax" + ([#7200](https://github.com/nim-lang/Nim/issues/7200)) +- Fixed "Impossible to create an empty const array" + ([#6853](https://github.com/nim-lang/Nim/issues/6853)) +- Fixed "Strange UINT handling" + ([#3985](https://github.com/nim-lang/Nim/issues/3985)) +- Fixed "Bad codegen when passing arg that is part of return value destination" + ([#6960](https://github.com/nim-lang/Nim/issues/6960)) +- Fixed "No info about gcsafety in error message when global var is accessed in async proc" + ([#6186](https://github.com/nim-lang/Nim/issues/6186)) +- Fixed "Resolving package vs. local import ambiguities" + ([#2819](https://github.com/nim-lang/Nim/issues/2819)) +- Fixed "Internal error with type() operator" + ([#3711](https://github.com/nim-lang/Nim/issues/3711)) +- Fixed "newAsyncSocket should raise an OS error plus other inconsistencies" + ([#4995](https://github.com/nim-lang/Nim/issues/4995)) +- Fixed "mapLiterals fails with negative values" + ([#7215](https://github.com/nim-lang/Nim/issues/7215)) +- Fixed "fmWrite doesn't truncate file with openAsync, unlike open()" + ([#5531](https://github.com/nim-lang/Nim/issues/5531)) +- Fixed "Move libsvm to an external nimble module" + ([#5786](https://github.com/nim-lang/Nim/issues/5786)) +- Fixed "Prevent acceptAddr gotcha with newSocket" + ([#7227](https://github.com/nim-lang/Nim/issues/7227)) +- Fixed "strtabs.getOrDefault is inconsistent with tables.getOrDefault" + ([#4265](https://github.com/nim-lang/Nim/issues/4265)) + +- Fixed "Code falling through into exception handler when no exception thrown." + ([#7232](https://github.com/nim-lang/Nim/issues/7232)) +- Fixed "the new generic inference rules are broken" + ([#7247](https://github.com/nim-lang/Nim/issues/7247)) +- Fixed "Odd `..<` regression" + ([#6992](https://github.com/nim-lang/Nim/issues/6992)) +- Fixed "Different proc type inferred from default parameter" + ([#4659](https://github.com/nim-lang/Nim/issues/4659)) +- Fixed "Different proc type inferred from default parameter" + ([#4659](https://github.com/nim-lang/Nim/issues/4659)) +- Fixed "Testament sometimes ignores test failures" + ([#7236](https://github.com/nim-lang/Nim/issues/7236)) +- Fixed "New Allocator Fails On >=4GB Requests" + ([#7120](https://github.com/nim-lang/Nim/issues/7120)) +- Fixed "User pragmas hide effect specifications from sempass2" + ([#7216](https://github.com/nim-lang/Nim/issues/7216)) +- Fixed "C++: SIGABRT instead of IndexError for out-of-bounds" + ([#6512](https://github.com/nim-lang/Nim/issues/6512)) +- Fixed "An uncaught exception in cpp mode doesn't show the exception name/msg" + ([#6431](https://github.com/nim-lang/Nim/issues/6431)) diff --git a/changelogs/changelog_0_19_0.md b/changelogs/changelog_0_19_0.md new file mode 100644 index 000000000..45cefe933 --- /dev/null +++ b/changelogs/changelog_0_19_0.md @@ -0,0 +1,253 @@ +## v0.19.X - XX/XX/2018 + +### Changes affecting backwards compatibility + +- The stdlib module ``future`` has been renamed to ``sugar``. +- ``macros.callsite`` is now deprecated. Since the introduction of ``varargs`` + parameters this became unnecessary. +- Anonymous tuples with a single element can now be written as ``(1,)`` with a + trailing comma. The underlying AST is ``nnkTupleConstr(newLit 1)`` for this + example. ``nnkTupleConstr`` is a new node kind your macros need to be able + to deal with! +- Indexing into a ``cstring`` for the JS target is now mapped + to ``charCodeAt``. +- Assignments that would "slice" an object into its supertype are now prevented + 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 + 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 + become an error in the future. +- The ``'c`` and ``'C'`` suffix for octal literals is now deprecated to + bring the language in line with the standard library (e.g. ``parseOct``). +- The dot style for import paths (e.g ``import path.to.module`` instead of + ``import path/to/module``) has been deprecated. + +#### Breaking changes in the standard library + +- ``re.split`` for empty regular expressions now yields every character in + the string which is what other programming languages chose to do. +- The returned tuple of ``system.instantiationInfo`` now has a third field + containing the column of the instantiation. + +- ``cookies.setCookie`` no longer assumes UTC for the expiration date. +- ``strutils.formatEng`` does not distinguish between ``nil`` and ``""`` + strings anymore for its ``unit`` parameter. Instead the space is controlled + by a new parameter ``useUnitSpace``. + +- The ``times.parse`` and ``times.format`` procs have been rewritten. + The proc signatures are the same so it should generally not break anything. + However, the new implementation is a bit stricter, which is a breaking change. + For example ``parse("2017-01-01 foo", "yyyy-MM-dd")`` will now raise an error. + +- ``proc `-`*(a, b: Time): int64`` in the ``times`` module has changed return type + to ``times.Duration`` in order to support higher time resolutions. + The proc is no longer deprecated. + +- The ``times.Timezone`` is now an immutable ref-type that must be initialized + with an explicit constructor (``newTimezone``). + +- ``posix.Timeval.tv_sec`` has changed type to ``posix.Time``. + +- ``math.`mod` `` for floats now behaves the same as ``mod`` for integers + (previously it used floor division like Python). Use ``math.floorMod`` for the old behavior. + +- For string inputs, ``unicode.isUpper`` and ``unicode.isLower`` now require a + second mandatory parameter ``skipNonAlpha``. + +- For string inputs, ``strutils.isUpperAscii`` and ``strutils.isLowerAscii`` now + require a second mandatory parameter ``skipNonAlpha``. + +- ``osLastError`` is now marked with ``sideEffect`` +- The procs ``parseHexInt`` and ``parseOctInt`` now fail on empty strings + and strings containing only valid prefixes, e.g. "0x" for hex integers. + +- ``terminal.setCursorPos`` and ``terminal.setCursorXPos`` now work correctly + with 0-based coordinates on POSIX (previously, you needed to use + 1-based coordinates on POSIX for correct behaviour; the Windows behaviour + was always correct). + +- ``lineInfoObj`` now returns absolute path instead of project path. + It's used by ``lineInfo``, ``check``, ``expect``, ``require``, etc. + +- ``net.sendTo`` no longer returns an int and now raises an ``OSError``. +- `threadpool`'s `await` and derivatives have been renamed to `blockUntil` + to avoid confusions with `await` from the `async` macro. + + +#### Breaking changes in the compiler + +- The undocumented ``#? braces`` parsing mode was removed. +- The undocumented PHP backend was removed. +- The default location of ``nimcache`` for the native code targets was + changed. Read [the compiler user guide](https://nim-lang.org/docs/nimc.html#generated-c-code-directory) + for more information. + +### Library additions + +- ``re.split`` now also supports the ``maxsplit`` parameter for consistency + with ``strutils.split``. +- Added ``system.toOpenArray`` in order to support zero-copy slicing + operations. This is currently not yet available for the JavaScript target. +- Added ``getCurrentDir``, ``findExe``, ``cpDir`` and ``mvDir`` procs to + ``nimscript``. +- The ``times`` module now supports up to nanosecond time resolution when available. +- Added the type ``times.Duration`` for representing fixed durations of time. +- Added the proc ``times.convert`` for converting between different time units, + e.g days to seconds. +- Added the proc ``algorithm.binarySearch[T, K]`` with the ```cmp``` parameter. +- Added the proc ``algorithm.upperBound``. +- Added inverse hyperbolic functions, ``math.arcsinh``, ``math.arccosh`` and ``math.arctanh`` procs. +- Added cotangent, secant and cosecant procs ``math.cot``, ``math.sec`` and ``math.csc``; and their hyperbolic, inverse and inverse hyperbolic functions, ``math.coth``, ``math.sech``, ``math.csch``, ``math.arccot``, ``math.arcsec``, ``math.arccsc``, ``math.arccoth``, ``math.arcsech`` and ``math.arccsch`` procs. +- Added the procs ``math.floorMod`` and ``math.floorDiv`` for floor based integer division. +- Added the procs ``rationals.`div```, ``rationals.`mod```, ``rationals.floorDiv`` and ``rationals.floorMod`` for rationals. +- Added the proc ``math.prod`` for product of elements in openArray. +- Added the proc ``parseBinInt`` to parse a binary integer from a string, which returns the value. +- ``parseOct`` and ``parseBin`` in parseutils now also support the ``maxLen`` argument similar to ``parseHexInt``. +- Added the proc ``flush`` for memory mapped files. +- Added the ``MemMapFileStream``. +- Added a simple interpreting event parser template ``eventParser`` to the ``pegs`` module. +- Added ``macros.copyLineInfo`` to copy lineInfo from other node. +- Added ``system.ashr`` an arithmetic right shift for integers. + +### Library changes + +- ``macros.astGenRepr``, ``macros.lispRepr`` and ``macros.treeRepr`` + now escapes the content of string literals consistently. +- ``macros.NimSym`` and ``macros.NimIdent`` is now deprecated in favor + of the more general ``NimNode``. +- ``macros.getImpl`` now includes the pragmas of types, instead of omitting them. +- ``macros.hasCustomPragma`` and ``macros.getCustomPragmaVal`` now + also support ``ref`` and ``ptr`` types, pragmas on types and variant + fields. +- ``system.SomeReal`` is now called ``SomeFloat`` for consistency and + correctness. +- ``algorithm.smartBinarySearch`` and ``algorithm.binarySearch`` is + now joined in ``binarySearch``. ``smartbinarySearch`` is now + deprecated. +- The `terminal` module now exports additional procs for generating ANSI color + codes as strings. +- Added the parameter ``val`` for the ``CritBitTree[int].inc`` proc. +- An exception raised from a ``test`` block of ``unittest`` now shows its type in + error message. +- The ``compiler/nimeval`` API was rewritten to simplify the "compiler as an + API". Using the Nim compiler and its VM as a scripting engine has never been + easier. See ``tests/compilerapi/tcompilerapi.nim`` for an example of how to + use the Nim VM in a native Nim application. +- Added the parameter ``val`` for the ``CritBitTree[T].incl`` proc. +- The proc ``tgamma`` was renamed to ``gamma``. ``tgamma`` is deprecated. +- The ``pegs`` module now exports getters for the fields of its ``Peg`` and ``NonTerminal`` + object types. ``Peg``s with child nodes now have the standard ``items`` and ``pairs`` + iterators. +- The ``accept`` socket procedure defined in the ``net`` module can now accept + a nil socket. + +### Language additions + +- Dot calls combined with explicit generic instantiations can now be written + as ``x.y[:z]`` which is transformed into ``y[z](x)`` by the parser. +- ``func`` is now an alias for ``proc {.noSideEffect.}``. +- In order to make ``for`` loops and iterators more flexible to use Nim now + supports so called "for-loop macros". See + the [manual](manual.html#macros-for-loop-macros) for more details. + This feature enables a Python-like generic ``enumerate`` implementation. + +- Case statements can now be rewritten via macros. See the [manual](manual.html#macros-case-statement-macros) for more information. + This feature enables custom pattern matchers. + + +- the `typedesc` special type has been renamed to just `type`. +- `static` and `type` are now also modifiers similar to `ref` and `ptr`. + They denote the special types `static[T]` and `type[T]`. +- Forcing compile-time evaluation with `static` now supports specifying + the desired target type (as a concrete type or as a type class) +- The `type` operator now supports checking that the supplied expression + matches an expected type constraint. + +### Language changes + +- The `importcpp` pragma now allows importing the listed fields of generic + C++ types. Support for numeric parameters have also been added through + the use of `static[T]` types. + (#6415) + +- Native C++ exceptions can now be imported with `importcpp` pragma. + Imported exceptions can be raised and caught just like Nim exceptions. + More details in language manual. + +- ``nil`` for strings/seqs is finally gone. Instead the default value for + these is ``"" / @[]``. Use ``--nilseqs:on`` for a transition period. + +- Accessing the binary zero terminator in Nim's native strings + is now invalid. Internally a Nim string still has the trailing zero for + zero-copy interoperability with ``cstring``. Compile your code with the + new switch ``--laxStrings:on`` if you need a transition period. + +- The command syntax now supports keyword arguments after the first comma. + +- Thread-local variables can now be declared inside procs. This implies all + the effects of the ``global`` pragma. + +- Nim now supports the ``except`` clause in the export statement. + +- Range float types, example ``range[0.0 .. Inf]``. More details in language manual. +- The ``{.this.}`` pragma has been deprecated. It never worked within generics and + we found the resulting code harder to read than the more explicit ``obj.field`` + syntax. +- "Memory regions" for pointer types have been deprecated, they were hardly used + anywhere. Note that this has **nothing** to do with the ``--gc:regions`` switch + of managing memory. + +- The exception hierarchy was slightly reworked, ``SystemError`` was renamed to + ``CatchableError`` and is the new base class for any exception that is guaranteed to + be catchable. This change should have minimal impact on most existing Nim code. + + +### Tool changes + +- ``jsondoc2`` has been renamed ``jsondoc``, similar to how ``doc2`` was renamed + ``doc``. The old ``jsondoc`` can still be invoked with ``jsondoc0``. + +### Compiler changes + +- The VM's instruction count limit was raised to 3 million instructions in + order to support more complex computations at compile-time. + +- Support for hot code reloading has been implemented for the JavaScript + target. To use it, compile your code with `--hotCodeReloading:on` and use a + helper library such as LiveReload or BrowserSync. + +- A new compiler option `--cppCompileToNamespace` puts the generated C++ code + into the namespace "Nim" in order to avoid naming conflicts with existing + C++ code. This is done for all Nim code - internal and exported. + +- Added ``macros.getProjectPath`` and ``os.putEnv`` procs to Nim's virtual + machine. + +- The ``deadCodeElim`` option is now always turned on and the switch has no + effect anymore, but is recognized for backwards compatibility. + +- ``experimental`` is now a pragma / command line switch that can enable specific + language extensions, it is not an all-or-nothing switch anymore. + +- Nintendo Switch was added as a new platform target. See [the compiler user guide](https://nim-lang.org/docs/nimc.html) + for more info. + +- macros.bindSym now capable to accepts not only literal string or string constant expression. + bindSym enhancement make it also can accepts computed string or ident node inside macros / + compile time functions / static blocks. Only in templates / regular code it retains it's old behavior. + This new feature can be accessed via {.experimental: "dynamicBindSym".} pragma/switch. + +- On Posix systems the global system wide configuration is now put under ``/etc/nim/nim.cfg``, + it used to be ``/etc/nim.cfg``. Usually it does not exist, however. + +- On Posix systems the user configuration is now looked under ``$XDG_CONFIG_HOME/nim/nim.cfg`` + (if ``XDG_CONFIG_HOME`` is not defined, then under ``~/.config/nim/nim.cfg``). It used to be + ``$XDG_CONFIG_DIR/nim.cfg`` (and ``~/.config/nim.cfg``). + + Similarly, on Windows, the user configuration is now looked under ``%APPDATA%/nim/nim.cfg``. + This used to be ``%APPDATA%/nim.cfg``. + +### Bugfixes diff --git a/changelogs/changelog_0_20_0.md b/changelogs/changelog_0_20_0.md new file mode 100644 index 000000000..9ddfd36dc --- /dev/null +++ b/changelogs/changelog_0_20_0.md @@ -0,0 +1,294 @@ +## v0.20.0 - 2019-06-06 + + +### Changes affecting backwards compatibility + +- `shr` is now sign preserving. Use `-d:nimOldShiftRight` to enable + the old behavior globally. + +- The ``isLower``, ``isUpper`` family of procs in strutils/unicode + operating on **strings** have been + deprecated since it was unclear what these do. Note that the much more + useful procs that operate on ``char`` or ``Rune`` are not affected. + +- `strutils.editDistance` has been deprecated, + use `editdistance.editDistance` or `editdistance.editDistanceAscii` + instead. + +- The OpenMP parallel iterator \``||`\` now supports any `#pragma omp directive` + and not just `#pragma omp parallel for`. See + [OpenMP documentation](https://www.openmp.org/wp-content/uploads/OpenMP-4.5-1115-CPP-web.pdf). + + The default annotation is `parallel for`, if you used OpenMP without annotation + the change is transparent, if you used annotations you will have to prefix + your previous annotations with `parallel for`. + + Furthermore, an overload with positive stepping is available. + +- The `unchecked` pragma was removed, instead use `system.UncheckedArray`. + +- The undocumented ``#? strongSpaces`` parsing mode has been removed. + +- The `not` operator is now always a unary operator, this means that code like + ``assert not isFalse(3)`` compiles. + +- `getImpl` on a `var` or `let` symbol will now return the full `IdentDefs` + tree from the symbol declaration instead of just the initializer portion. + +- Methods are now ordinary "single" methods, only the first parameter is + used to select the variant at runtime. For backwards compatibility + use the new `--multimethods:on` switch. + +- Generic methods are now deprecated; they never worked well. + +- Compile time checks for integer and float conversions are now stricter. + For example, `const x = uint32(-1)` now gives a compile time error instead + of being equivalent to `const x = 0xFFFFFFFF'u32`. + +- Using `typed` as the result type in templates/macros now means + "expression with a type". The old meaning of `typed` is preserved + as `void` or no result type at all. + +- A bug allowed `macro foo(): int = 123` to compile even though a + macro has to return a `NimNode`. This has been fixed. + +- With the exception of `uint` and `uint64`, conversion to unsigned types + are now range checked during runtime. + +- Macro arguments of type `typedesc` are now passed to the macro as + `NimNode` like every other type except `static`. Use `typed` for a + behavior that is identical in new and old + Nim. See the RFC [Pass typedesc as NimNode to macros](https://github.com/nim-lang/RFCs/issues/148) + for more details. + + +#### Breaking changes in the standard library + +- `osproc.execProcess` now also takes a `workingDir` parameter. + +- `std/sha1.secureHash` now accepts `openArray[char]`, not `string`. (Former + successful matches should keep working, though former failures will not.) + +- `options.UnpackError` is no longer a ref type and inherits from `system.Defect` + instead of `system.ValueError`. + +- `system.ValueError` now inherits from `system.CatchableError` instead of `system.Defect`. + +- The procs `parseutils.parseBiggestInt`, `parseutils.parseInt`, + `parseutils.parseBiggestUInt` and `parseutils.parseUInt` now raise a + `ValueError` when the parsed integer is outside of the valid range. + Previously they sometimes raised an `OverflowError` and sometimes they + returned `0`. + +- The procs `parseutils.parseBin`, `parseutils.parseOct` and `parseutils.parseHex` + were not clearing their `var` parameter `number` and used to push its value to + the left when storing the parsed string into it. Now they always set the value + of the parameter to `0` before storing the result of the parsing, unless the + string to parse is not valid (then the value of `number` is not changed). + +- `streams.StreamObject` now restricts its fields to only raise `system.Defect`, + `system.IOError` and `system.OSError`. + This change only affects custom stream implementations. + +- nre's `RegexMatch.{captureBounds,captures}[]` no longer return `Option` or + `nil`/`""`, respectively. Use the newly added `n in p.captures` method to + check if a group is captured, otherwise you'll receive an exception. + +- nre's `RegexMatch.{captureBounds,captures}.toTable` no longer accept a + default parameter. Instead uncaptured entries are left empty. Use + `Table.getOrDefault()` if you need defaults. + +- nre's `RegexMatch.captures.{items,toSeq}` now returns an `Option[string]` + instead of a `string`. With the removal of `nil` strings, this is the only + way to indicate a missing match. Inside your loops, instead + of `capture == ""` or `capture == nil`, use `capture.isSome` to check if a capture is + present, and `capture.get` to get its value. + +- nre's `replace()` no longer throws `ValueError` when the replacement string + has missing captures. It instead throws `KeyError` for named captures, and + `IndexError` for unnamed captures. This is consistent with + `RegexMatch.{captureBounds,captures}[]`. + +- `splitFile` now correctly handles edge cases, see #10047. + +- `isNil` is no longer false for undefined in the JavaScript backend: + now it's true for both nil and undefined. + Use `isNull` or `isUndefined` if you need exact equality: + `isNil` is consistent with `===`, `isNull` and `isUndefined` with `==`. + +- several deprecated modules were removed: `ssl`, `matchers`, `httpserver`, + `unsigned`, `actors`, `parseurl` + +- two poorly documented and not used modules (`subexes`, `scgi`) were moved to + graveyard (they are available as Nimble packages) + +- procs `string.add(int)` and `string.add(float)` which implicitly convert + ints and floats to string have been deprecated. + Use `string.addInt(int)` and `string.addFloat(float)` instead. + +- ``case object`` branch transitions via ``system.reset`` are deprecated. + Compile your code with ``-d:nimOldCaseObjects`` for a transition period. + +- base64 module: The default parameter `newLine` for the `encode` procs + was changed from `"\13\10"` to the empty string `""`. + + +#### Breaking changes in the compiler + +- The compiler now implements the "generic symbol prepass" for `when` statements + in generics, see bug #8603. This means that code like this does not compile + anymore: + +```nim +proc enumToString*(enums: openArray[enum]): string = + # typo: 'e' instead 'enums' + when e.low.ord >= 0 and e.high.ord < 256: + result = newString(enums.len) + else: + result = newString(enums.len * 2) +``` + +- ``discard x`` is now illegal when `x` is a function symbol. + +- Implicit imports via ``--import: module`` in a config file are now restricted + to the main package. + + +### Library additions + +- There is a new stdlib module `std/editdistance` as a replacement for the + deprecated `strutils.editDistance`. + +- There is a new stdlib module `std/wordwrap` as a replacement for the + deprecated `strutils.wordwrap`. + +- Added `split`, `splitWhitespace`, `size`, `alignLeft`, `align`, + `strip`, `repeat` procs and iterators to `unicode.nim`. + +- Added `or` for `NimNode` in `macros`. + +- Added `system.typeof` for more control over how `type` expressions + can be deduced. + +- Added `macros.isInstantiationOf` for checking if the proc symbol + is instantiation of generic proc symbol. + +- Added the parameter ``isSorted`` for the ``sequtils.deduplicate`` proc. + +- There is a new stdlib module `std/diff` to compute the famous "diff" + of two texts by line. + +- Added `os.relativePath`. + +- Added `parseopt.remainingArgs`. + +- Added `os.getCurrentCompilerExe` (implemented as `getAppFilename` at CT), + can be used to retrieve the currently executing compiler. + +- Added `xmltree.toXmlAttributes`. + +- Added ``std/sums`` module for fast summation functions. + +- Added `Rusage`, `getrusage`, `wait4` to the posix interface. + +- Added the `posix_utils` module. + +- Added `system.default`. + +- Added `sequtils.items` for closure iterators, allows closure iterators + to be used by the `mapIt`, `filterIt`, `allIt`, `anyIt`, etc. + + +### Library changes + +- The string output of `macros.lispRepr` proc has been tweaked + slightly. The `dumpLisp` macro in this module now outputs an + indented proper Lisp, devoid of commas. + +- Added `macros.signatureHash` that returns a stable identifier + derived from the signature of a symbol. + +- In `strutils` empty strings now no longer matched as substrings + anymore. + +- The `Complex` type is now a generic object and not a tuple anymore. + +- The `ospaths` module is now deprecated, use `os` instead. Note that + `os` is available in a NimScript environment but unsupported + operations produce a compile-time error. + +- The `parseopt` module now supports a new flag `allowWhitespaceAfterColon` + (default value: true) that can be set to `false` for better Posix + interoperability. (Bug #9619.) + +- `os.joinPath` and `os.normalizePath` handle edge cases like ``"a/b/../../.."`` + differently. + +- `securehash` was moved to `lib/deprecated`. + +- The switch ``-d:useWinAnsi`` is not supported anymore. + +- In `times` module, procs `format` and `parse` accept a new optional + `DateTimeLocale` argument for formatting/parsing dates in other languages. + + +### Language additions + +- Vm support for float32<->int32 and float64<->int64 casts was added. +- There is a new pragma block `noSideEffect` that works like + the `gcsafe` pragma block. +- added `os.getCurrentProcessId`. +- User defined pragmas are now allowed in the pragma blocks. +- Pragma blocks are no longer eliminated from the typed AST tree to preserve + pragmas for further analysis by macros. +- Custom pragmas are now supported for `var` and `let` symbols. +- Tuple unpacking is now supported for constants and for loop variables. +- Case object branches can be initialized with a runtime discriminator if + possible discriminator values are constrained within a case statement. + +### Language changes + +- The standard extension for SCF (source code filters) files was changed from + ``.tmpl`` to ``.nimf``, + it's more recognizable and allows tools like Github to recognize it as Nim, + see [#9647](https://github.com/nim-lang/Nim/issues/9647). + The previous extension will continue to work. + +- Pragma syntax is now consistent. Previous syntax where type pragmas did not + follow the type name is now deprecated. Also pragma before generic parameter + list is deprecated to be consistent with how pragmas are used with a proc. See + [#8514](https://github.com/nim-lang/Nim/issues/8514) and + [#1872](https://github.com/nim-lang/Nim/issues/1872) for further details. + +- Hash sets and tables are initialized by default. The explicit `initHashSet`, + `initTable`, etc. are not needed anymore. + + +### Tool changes + +- `jsondoc` now includes a `moduleDescription` field with the module + description. `jsondoc0` shows comments as its own objects as shown in the + documentation. +- `nimpretty`: --backup now defaults to `off` instead of `on` and the flag was + undocumented; use `git` instead of relying on backup files. +- `koch` now defaults to build the latest *stable* Nimble version unless you + explicitly ask for the latest master version via `--latest`. + + +### Compiler changes + +- The deprecated `fmod` proc is now unavailable on the VM. +- A new `--outdir` option was added. +- The compiled JavaScript file for the project produced by executing `nim js` + will no longer be placed in the nimcache directory. +- The `--hotCodeReloading` has been implemented for the native targets. + The compiler also provides a new more flexible API for handling the + hot code reloading events in the code. +- The compiler now supports a ``--expandMacro:macroNameHere`` switch + for easy introspection into what a macro expands into. +- The `-d:release` switch now does not disable runtime checks anymore. + For a release build that also disables runtime checks + use `-d:release -d:danger` or simply `-d:danger`. + + +### Bugfixes diff --git a/changelogs/changelog_0_20_2.md b/changelogs/changelog_0_20_2.md new file mode 100644 index 000000000..4f09ae3c5 --- /dev/null +++ b/changelogs/changelog_0_20_2.md @@ -0,0 +1,55 @@ +# v0.20.2 - 2019-07-17 + + +## Changes affecting backwards compatibility + +- All `strutils.rfind` procs now take `start` and `last` like `strutils.find` + with the same data slice/index meaning. This is backwards compatible for + calls *not* changing the `rfind` `start` parameter from its default. (#11487) + + In the unlikely case that you were using `rfind X, start=N`, or `rfind X, N`, + then you need to change that to `rfind X, last=N` or `rfind X, 0, N`. (This + should minimize gotchas porting code from other languages like Python or C++.) + +- On Windows stderr/stdout/stdin are not opened as binary files anymore. Use the switch + `-d:nimBinaryStdFiles` for a transition period. + +### Breaking changes in the standard library + +- Mac OS X / BSD: TSa_Family is now the ``uint8`` type, so type + conversions like ``x.sin_family = uint16 toInt(nativesockets.AF_INET)`` + need to be changed into ``x.sin_family = TSa_Family toInt(nativesockets.AF_INET)``. + + +### Breaking changes in the compiler + + +## Library additions + +- `toOpenArray` is now available for the JS target. + +## Library changes + +- Fix async IO operations stalling even after socket is closed. (#11232) + +- More informative error message for `streams.openFileStream`. (#11438) + + +## Language additions + + +## Language changes + + +### Tool changes + + +### Compiler changes + +- Better error message for IndexError for empty containers. (#11476) + +- Fix regression in semfold for old right shift. (#11477) + +- Fix for passing tuples as static params to macros. (#11423) + +## Bugfixes diff --git a/changelogs/changelog_1_0_0.md b/changelogs/changelog_1_0_0.md new file mode 100644 index 000000000..5a9185ecb --- /dev/null +++ b/changelogs/changelog_1_0_0.md @@ -0,0 +1,138 @@ +# v1.0 - 2019-09-23 + + +## Changes affecting backwards compatibility + +- The switch ``-d:nimBinaryStdFiles`` does not exist anymore. Instead + stdin/stdout/stderr are binary files again. This change only affects + Windows. + +- On Windows console applications the code-page is set at program startup + to UTF-8. Use the new switch `-d:nimDontSetUtf8CodePage` to disable this + feature. + +- The language definition and compiler are now stricter about ``gensym``'ed + symbols in hygienic templates. See the section in the + [manual](https://nim-lang.org/docs/manual.html#templates-hygiene-in-templates) + for further details. Use the compiler switch `--oldgensym:on` for a + transition period. + + +### Breaking changes in the standard library + +- We removed `unicode.Rune16` without any deprecation period as the name + was wrong (see the [RFC](https://github.com/nim-lang/RFCs/issues/151) for details) + and we didn't find any usages of it in the wild. If you still need it, add this + piece of code to your project: +```nim +type + Rune16* = distinct int16 +``` + +- `exportc` now uses C instead of C++ mangling with `nim cpp`, matching behavior + of `importc`, see #10578. + Use the new `exportcpp` to mangle as C++ when using `nim cpp`. + + +### Breaking changes in the compiler + +- A bug allowing `int` to be implicitly converted to range types of smaller size + (e.g `range[0'i8..10'i8]`) has been fixed. + + + +## Library additions + +- `encodings.getCurrentEncoding` now distinguishes between the console's + encoding and the OS's encoding. This distinction is only meaningful on + Windows. +- Added `system.getOsFileHandle` which is usually more useful + than `system.getFileHandle`. This distinction is only meaningful on + Windows. +- Added a `json.parseJsonFragments` iterator that can be used to speedup + JSON processing substantially when there are JSON fragments separated + by whitespace. + + + +## Library changes + +- Added `os.delEnv` and `nimscript.delEnv`. (#11466) + +- Enabled Oid usage in hashtables. (#11472) + +- Added `unsafeColumnAt` procs, that return unsafe cstring from InstantRow. (#11647) + +- Make public `Sha1Digest` and `Sha1State` types and `newSha1State`, + `update` and `finalize` procedures from `sha1` module. (#11694) + +- Added the `std/monotimes` module which implements monotonic timestamps. + +- Consistent error handling of two `exec` overloads. (#10967) + +- Officially the following modules now have an unstable API: + - std/varints + - core/allocators + - core/hotcodereloading + - asyncstreams + - base64 + - browsers + - collections/rtarrays + - collections/sharedlist + - collections/sharedtable + - concurrency/atomics + - concurrency/cpuload + - concurrency/threadpool + - coro + - endians + - httpcore + - parsesql + - pathnorm + - reservedmem + - typetraits + + Every other stdlib module is API stable with respect to version 1. + + + +## Language additions + +- Inline iterators returning `lent T` types are now supported, similarly to + iterators returning `var T`: +```nim +iterator myitems[T](x: openarray[T]): lent T +iterator mypairs[T](x: openarray[T]): tuple[idx: int, val: lent T] +``` + +- Added an `importjs` pragma that can now be used instead of `importcpp` + and `importc` to import symbols from JavaScript. `importjs` for routines always + takes a "pattern" for maximum flexibility. + + + +## Language changes + +- `uint64` is now finally a regular ordinal type. This means `high(uint64)` compiles + and yields the correct value. + + +### Tool changes + +- The Nim compiler now does not recompile the Nim project via ``nim c -r`` if + no dependent Nim file changed. This feature can be overridden by + the ``--forceBuild`` command line option. +- The Nim compiler now warns about unused module imports. You can use a + top level ``{.used.}`` pragma in the module that you want to be importable + without producing this warning. +- The "testament" testing tool's name was changed + from `tester` to `testament` and is generally available as a tool to run Nim + tests automatically. + + +### Compiler changes + +- VM can now cast integer type arbitrarily. (#11459) + + + +## Bugfixes diff --git a/changelogs/changelog_1_0_2.md b/changelogs/changelog_1_0_2.md new file mode 100644 index 000000000..aa01c503f --- /dev/null +++ b/changelogs/changelog_1_0_2.md @@ -0,0 +1,56 @@ +# v1.0.2 - 2019-10-23 + + +## Bugfixes + +* fixes the --verbosity:2 regression +* Fixed "Fail to compile a file twice under Windows (v1.0 bug)." [#12242](https://github.com/nim-lang/Nim/issues/12242) +* fix nimpretty removing space before pragma +* JS: gensym is stricter for 'this' +* Fixed "VM Assertion Error with newruntime" [#12294](https://github.com/nim-lang/Nim/issues/12294) +* Fixed "Assertion error when running `nim check` on compiler/nim.nim" [#12281](https://github.com/nim-lang/Nim/issues/12281) +* Fixed "Compiler crash with empty array and generic instantiation with int as parameter" [#12264](https://github.com/nim-lang/Nim/issues/12264) +* Fixed "Regression in JS backend codegen "Error: request to generate code for .compileTime proc"" [#12240](https://github.com/nim-lang/Nim/issues/12240) +* Fix how `relativePath` handle case sensitiviy +* Fixed "SIGSEGV in compiler when using generic types and seqs" [#12336](https://github.com/nim-lang/Nim/issues/12336) +* Fixed "[1.0.0] weird interaction between `import os` and casting integer to char on macosx trigger bad codegen" [#12291](https://github.com/nim-lang/Nim/issues/12291) +* VM: no special casing for big endian machines +* Fixed "`internal error: environment misses` with a simple template inside one of Jester macros" [#12323](https://github.com/nim-lang/Nim/issues/12323) +* nimsuggest: fix tcp socket leak +* nimsuggest: fix tcp socket leak for epc backend +* Fixed "`writeFile` and `write(f, str)` skip null bytes on Windows" [#12315](https://github.com/nim-lang/Nim/issues/12315) +* Fixed "Crash in intsets symmetric_difference" [#12366](https://github.com/nim-lang/Nim/issues/12366) +* Fixed "[regression] VM crash when dealing with var param of a proc result" [#12244](https://github.com/nim-lang/Nim/issues/12244) +* fixes a koch regression that made 'koch boot --listcmd' not work anymore +* Fixed "[regression] inconsistent signed int `mod` operator between runtime, compiletime, and semfold" [#12332](https://github.com/nim-lang/Nim/issues/12332) +* Fixed "Boehm disables interior pointer checking" [#12286](https://github.com/nim-lang/Nim/issues/12286) +* Fixes semCustomPragma when nkSym +* Fixed yield in nkCheckedFieldExpr +* Fixed "`randomize()` from `random` not working on JS" [#12418](https://github.com/nim-lang/Nim/issues/12418) +* Fixed "Compiler crash with invalid object variant" [#12379](https://github.com/nim-lang/Nim/issues/12379) +* fix type's case in random.nim +* Fixed "Update docs with a better way to signal unimplemented methods" [#10804](https://github.com/nim-lang/Nim/issues/10804) +* Fixed "Nim language manual, push pragma is not explained well" [#10824](https://github.com/nim-lang/Nim/issues/10824) +* Fixed "[regression] Importing more than one module with same name from different packages produce bad codegen" [#12420](https://github.com/nim-lang/Nim/issues/12420) +* Namespace unittest enums to avoid name conflicts +* Fixed "VM checks unsigned integers for overflow." [#12310](https://github.com/nim-lang/Nim/issues/12310) +* Fixed "line directive is not generated for first line of function definition" [#12426](https://github.com/nim-lang/Nim/issues/12426) + + + +## Documentation improvements + +* threadpool: fix link in docs (#12258) +* Fix spellings (#12277) +* fix #12278, don't expose internal PCRE documentation +* Fixed "Documentation of quitprocs is wrong" [#12279(https://github.com/nim-lang/Nim/issues/12279) +* Fix typo in docs +* Fix reference to parseSpec proc in readme +* [doc/tut1] removed discard discussion in comments +* Documentation improvements around the db interface +* Easier build instructions for windows - just run `build_all.bat`. +* fix a few dead links and a missing sentence in documentation +* Macro docs additions +* Updated the code example in the os module to use better grammar. +* Mention "lambdas" and `=>` in the manual +* Better documentation on Garbage Collector diff --git a/changelogs/changelog_1_2_0.md b/changelogs/changelog_1_2_0.md new file mode 100644 index 000000000..1f76df0b4 --- /dev/null +++ b/changelogs/changelog_1_2_0.md @@ -0,0 +1,535 @@ +# v1.2.0 - 2020-04-02 + + +## Standard library additions and changes +- Added overloaded `strformat.fmt` macro that use specified characters as + delimiter instead of '{' and '}'. +- Added new procs in `tables.nim`: `OrderedTable.pop`, `CountTable.del`, + `CountTable.pop`, `Table.pop`. +- Added `strtabs.clear` overload that reuses the existing mode. +- Added `browsers.osOpen` const alias for the operating system specific *"open"* command. +- Added `sugar.dup` for turning in-place algorithms like `sort` and `shuffle` + into operations that work on a copy of the data and return the mutated copy, + like the existing `sorted` does. +- Added `sugar.collect` that does comprehension for seq/set/table collections. +- Added `sugar.capture` for capturing some local loop variables when creating a + closure. This is an enhanced version of `closureScope`. +- Added `typetraits.tupleLen` to get number of elements of a tuple/type tuple, + and `typetraits.get` to get the ith element of a type tuple. +- Added `typetraits.genericParams` to return a tuple of generic params from a + generic instantiation. +- `options` now treats `proc` like other pointer types, meaning `nil` proc variables + are converted to `None`. +- Added `os.normalizePathEnd` for additional path sanitization. +- Added `times.fromUnixFloat,toUnixFloat`, sub-second resolution versions of + `fromUnix`,`toUnixFloat`. +- Added `wrapnils` module for chains of field-access and indexing where the LHS + can be nil. This simplifies code by reducing need for if-else branches around + intermediate maybe nil values. E.g. `echo ?.n.typ.kind`. +- Added `minIndex`, `maxIndex` and `unzip` to the `sequtils` module. +- Added `os.isRelativeTo` to tell whether a path is relative to another. +- Added `resetOutputFormatters` to `unittest`. +- Added `expectIdent` to the `macros` module. +- Added `os.isValidFilename` that returns `true` if `filename` argument is valid + for cross-platform use. +- Added `times.isLeapDay`. +- `base64` adds URL-Safe Base64, implements RFC-4648 Section-7. +- Added a new module, `std / compilesettings` for querying the compiler about + diverse configuration settings. +- Added `net.getPeerCertificates` and `asyncnet.getPeerCertificates` for + retrieving the verified certificate chain of the peer we are connected to + through an SSL-wrapped `Socket`/`AsyncSocket`. +- Added `browsers.openDefaultBrowser` without URL, implements IETF RFC-6694 Section-3. +- Added `jsconsole.trace`, `jsconsole.table`, `jsconsole.exception` for JavaScript target. +- Added `distinctBase` overload for values: `assert 12.MyInt.distinctBase == 12` +- Added new module `std/stackframes`, in particular `setFrameMsg`, which enables + custom runtime annotation of stackframes, see #13351 for examples. + Turn on/off via `--stackTraceMsgs:on/off`. +- Added `sequtils.countIt`, allowing for counting items using a predicate. +- Added a `with` macro for easy function chaining that's available everywhere, + there is no need to concern your APIs with returning the first argument + to enable "chaining", instead use the dedicated macro `with` that + was designed for it. For example: + +```nim +import std/with + +type + Foo = object + col, pos: string + +proc setColor(f: var Foo; r, g, b: int) = f.col = $(r, g, b) +proc setPosition(f: var Foo; x, y: float) = f.pos = $(x, y) + +var f: Foo +with(f, setColor(2, 3, 4), setPosition(0.0, 1.0)) +echo f +``` + +- `macros.newLit` now works for ref object types. +- `macro pragmas` can now be used in type sections. +- 5 new pragmas were added to Nim in order to make the upcoming tooling more + convenient to use. Nim compiler checks these pragmas for syntax but otherwise + ignores them. The pragmas are `requires`, `ensures`, `assume`, `assert`, `invariant`. +- `system.writeFile` has been overloaded to also support `openarray[byte]`. +- `asyncdispatch.drain` now properly takes into account `selector.hasPendingOperations` + and only returns once all pending async operations are guaranteed to have completed. +- `sequtils.zip` now returns a sequence of anonymous tuples i.e. those tuples + now do not have fields named "a" and "b". +- `distinctBase` has been moved from `sugar` to `typetraits` and now it is + implemented as compiler type trait instead of macro. `distinctBase` in sugar + module is now deprecated. +- `CountTable.mget` has been removed from `tables.nim`. It didn't work, and it + was an oversight to be included in v1.0. +- `tables.merge(CountTable, CountTable): CountTable` has been removed. + It didn't work well together with the existing inplace version of the same proc + (`tables.merge(var CountTable, CountTable)`). + It was an oversight to be included in v1.0. +- `asyncdispatch.drain` now consistently uses the passed timeout value for all + iterations of the event loop, and not just the first iteration. + This is more consistent with the other asyncdispatch APIs, and allows + `asyncdispatch.drain` to be more efficient. +- `base64.encode` and `base64.decode` were made faster by about 50%. +- `htmlgen` adds [MathML](https://wikipedia.org/wiki/MathML) support + (ISO 40314). +- `macros.eqIdent` is now invariant to export markers and backtick quotes. +- `htmlgen.html` allows `lang` in the `<html>` tag and common valid attributes. +- `macros.basename` and `basename=` got support for `PragmaExpr`, + so that an expression like `MyEnum {.pure.}` is handled correctly. +- `httpclient.maxredirects` changed from `int` to `Natural`, because negative values + serve no purpose whatsoever. +- `httpclient.newHttpClient` and `httpclient.newAsyncHttpClient` added `headers` + argument to set initial HTTP Headers, instead of a hardcoded empty `newHttpHeader()`. +- `parseutils.parseUntil` has now a different behaviour if the `until` parameter is + empty. This was required for intuitive behaviour of the strscans module + (see bug #13605). +- `strutils.formatFloat` with `precision = 0` has the same behavior in all + backends, and it is compatible with Python's behavior, + e.g. `formatFloat(3.14159, precision = 0)` is now `3`, not `3.`. +- `times.parse` now only uses input to compute its result, and not `now`: + `parse("2020", "YYYY", utc())` is now `2020-01-01T00:00:00Z` instead of + `2020-03-02T00:00:00Z` if run on 03-02; it also doesn't crash anymore when + used on 29th, 30th, 31st of each month. +- `httpcore.==(string, HttpCode)` is now deprecated due to lack of practical + usage. The `$` operator can be used to obtain the string form of `HttpCode` + for comparison if desired. +- `std/oswalkdir` was buggy, it's now deprecated and reuses `std/os` procs. +- `os.walkDir` and `os.walkDirRec` now have new flag, `checkDir` (default: false). + If it is set to true, it will throw if input dir is invalid instead of a noop + (which is the default behaviour, as it was before this change), + `os.walkDirRec` only throws if top-level dir is invalid, but ignores errors for + subdirs, otherwise it would be impossible to resume iteration. +- The `FD` variant of `selector.unregister` for `ioselector_epoll` and + `ioselector_select` now properly handle the `Event.User` select event type. +- `joinPath` path normalization when `/` is the first argument works correctly: + `assert "/" / "/a" == "/a"`. Fixed the edge case: `assert "" / "" == ""`. +- `xmltree` now adds indentation consistently to child nodes for any number + of children nodes. +- `os.splitPath()` behavior synchronized with `os.splitFile()` to return "/" + as the dir component of `/root_sub_dir` instead of the empty string. +- The deprecated `lc` macro has been removed from `sugar`. It is now replaced + with the more powerful `collect` macro. +- `os.relativePath("foo", "foo")` is now `"."`, not `""`, as `""` means invalid + path and shouldn't be conflated with `"."`; use `-d:nimOldRelativePathBehavior` + to restore the old behavior. +- `os.joinPath(a, b)` now honors trailing slashes in `b` (or `a` if `b` = ""). +- `base64.encode` no longer supports `lineLen` and `newLine`. + Use `base64.encodeMime` instead. + + +### Breaking changes + +- `net.newContext` now performs SSL Certificate checking on Linux and OSX. + Define `nimDisableCertificateValidation` to disable it globally. + + + +## Language changes + +- An `align` pragma can now be used for variables and object fields, similar + to the `alignas` declaration modifier in C/C++. +- The `=sink` type bound operator is now optional. The compiler can now use a + combination of `=destroy` and `copyMem` to move objects efficiently. +- Unsigned integer operators have been fixed to allow promotion of the first operand. +- Conversions to unsigned integers are unchecked at runtime, imitating earlier Nim + versions. The documentation was improved to acknowledge this special case. + See https://github.com/nim-lang/RFCs/issues/175 for more details. +- There is a new syntax for lvalue references: `var b {.byaddr.} = expr` enabled by + `import std/decls`. +- `var a {.foo.}: MyType = expr` now lowers to `foo(a, MyType, expr)` for + non-builtin pragmas, enabling things like lvalue references (see `decls.byaddr`). + + + +## Compiler changes + +- The generated JS code uses spaces, instead of mixing spaces and tabs. +- The Nim compiler now supports the ``--asm`` command option for easier + inspection of the produced assembler code. +- The Nim compiler now supports a new pragma called ``.localPassc`` to + pass specific compiler options to the C(++) backend for the C(++) file + that was produced from the current Nim module. +- The compiler now inferes "sink parameters". To disable this for a specific routine, + annotate it with `.nosinks`. To disable it for a section of code, use + `{.push sinkInference: off.}`...`{.pop.}`. +- The compiler now supports a new switch `--panics:on` that turns runtime + errors like `IndexError` or `OverflowError` into fatal errors that **cannot** + be caught via Nim's `try` statement. `--panics:on` can improve the + runtime efficiency and code size of your program significantly. +- The compiler now warns about inheriting directly from `system.Exception` as + this is **very bad** style. You should inherit from `ValueError`, `IOError`, + `OSError` or from a different specific exception type that inherits from + `CatchableError` and cannot be confused with a `Defect`. +- The error reporting for Nim's effect system has been improved. +- Implicit conversions for `const` behave correctly now, meaning that code like + `const SOMECONST = 0.int; procThatTakesInt32(SOMECONST)` will be illegal now. + Simply write `const SOMECONST = 0` instead. +- The `{.dynlib.}` pragma is now required for exporting symbols when making + shared objects on POSIX and macOS, which make it consistent with the behavior + on Windows. +- The compiler is now more strict about type conversions concerning proc + types: Type conversions cannot be used to hide `.raise` effects or side + effects, instead a `cast` must be used. With the flag `--useVersion:1.0` the + old behaviour is emulated. +- The Nim compiler now implements a faster way to detect overflows based + on GCC's `__builtin_sadd_overflow` family of functions. (Clang also + supports these). Some versions of GCC lack this feature and unfortunately + we cannot detect this case reliably. So if you get compilation errors like + "undefined reference to `__builtin_saddll_overflow`" compile your programs + with `-d:nimEmulateOverflowChecks`. + + + + +## Bugfixes + +- Fixed "`nimgrep --nocolor` is ignored on posix; should be instead: `--nimgrep --color=[auto]|true|false`" + ([#7591](https://github.com/nim-lang/Nim/issues/7591)) +- Fixed "Runtime index on const array (of converted obj) causes C-compiler error" + ([#10514](https://github.com/nim-lang/Nim/issues/10514)) +- Fixed "windows x86 with vcc compile error with "asmNoStackFrame"" + ([#12298](https://github.com/nim-lang/Nim/issues/12298)) +- Fixed "[TODO] regression: Error: Locks requires --threads:on option" + ([#12330](https://github.com/nim-lang/Nim/issues/12330)) +- Fixed "Add --cc option to --help or --fullhelp output" + ([#12010](https://github.com/nim-lang/Nim/issues/12010)) +- Fixed "questionable `csize` definition in `system.nim`" + ([#12187](https://github.com/nim-lang/Nim/issues/12187)) +- Fixed "os.getAppFilename() returns incorrect results on OpenBSD" + ([#12389](https://github.com/nim-lang/Nim/issues/12389)) +- Fixed "HashSet[uint64] slow insertion depending on values" + ([#11764](https://github.com/nim-lang/Nim/issues/11764)) +- Fixed "Differences between compiling 'classic call syntax' vs 'method call syntax' ." + ([#12453](https://github.com/nim-lang/Nim/issues/12453)) +- Fixed "c -d:nodejs --> SIGSEGV: Illegal storage access" + ([#12502](https://github.com/nim-lang/Nim/issues/12502)) +- Fixed "Closure iterator crashes on --newruntime due to "dangling references"" + ([#12443](https://github.com/nim-lang/Nim/issues/12443)) +- Fixed "No `=destroy` for elements of closure environments other than for latest devel --gc:destructors" + ([#12577](https://github.com/nim-lang/Nim/issues/12577)) +- Fixed "strutils:formatBiggestFloat() gives different results in JS mode" + ([#8242](https://github.com/nim-lang/Nim/issues/8242)) +- Fixed "Regression (devel): the new `csize_t` definition isn't consistently used, nor tested thoroughly..." + ([#12597](https://github.com/nim-lang/Nim/issues/12597)) +- Fixed "tables.take() is defined only for `Table` and missed for other table containers" + ([#12519](https://github.com/nim-lang/Nim/issues/12519)) +- Fixed "`pthread_key_t` errors on OpenBSD" + ([#12135](https://github.com/nim-lang/Nim/issues/12135)) +- Fixed "newruntime: simple seq pop at ct results in compile error" + ([#12644](https://github.com/nim-lang/Nim/issues/12644)) +- Fixed "[Windows] finish.exe C:\Users\<USERNAME>\.nimble\bin is not in your PATH environment variable." + ([#12319](https://github.com/nim-lang/Nim/issues/12319)) +- Fixed "Error with strformat + asyncdispatch + const" + ([#12612](https://github.com/nim-lang/Nim/issues/12612)) +- Fixed "MultipartData needs $" + ([#11863](https://github.com/nim-lang/Nim/issues/11863)) +- Fixed "Nim stdlib style issues with --styleCheck:error" + ([#12687](https://github.com/nim-lang/Nim/issues/12687)) +- Fixed "new $nimbleDir path substitution yields unexpected search paths" + ([#12767](https://github.com/nim-lang/Nim/issues/12767)) +- Fixed "Regression: inlined procs now get multiple rounds of destructor injection" + ([#12766](https://github.com/nim-lang/Nim/issues/12766)) +- Fixed "newruntime: compiler generates defective code" + ([#12669](https://github.com/nim-lang/Nim/issues/12669)) +- Fixed "broken windows modules path handling because of 'os.relativePath' breaking changes" + ([#12734](https://github.com/nim-lang/Nim/issues/12734)) +- Fixed "for loop tuple syntax not rendered correctly" + ([#12740](https://github.com/nim-lang/Nim/issues/12740)) +- Fixed "Crash when trying to use `type.name[0]`" + ([#12804](https://github.com/nim-lang/Nim/issues/12804)) +- Fixed "Enums should be considered Trivial types in Atomics" + ([#12812](https://github.com/nim-lang/Nim/issues/12812)) +- Fixed "Produce static/const initializations for variables when possible" + ([#12216](https://github.com/nim-lang/Nim/issues/12216)) +- Fixed "Assigning descriminator field leads to internal assert with --gc:destructors" + ([#12821](https://github.com/nim-lang/Nim/issues/12821)) +- Fixed "nimsuggest `use` command does not return all instances of symbol" + ([#12832](https://github.com/nim-lang/Nim/issues/12832)) +- Fixed "@[] is a problem for --gc:destructors" + ([#12820](https://github.com/nim-lang/Nim/issues/12820)) +- Fixed "Codegen ICE in allPathsAsgnResult" + ([#12827](https://github.com/nim-lang/Nim/issues/12827)) +- Fixed "seq[Object with ref and destructor type] doesn't work in old runtime" + ([#12882](https://github.com/nim-lang/Nim/issues/12882)) +- Fixed "Destructor not invoked because it is instantiated too late, old runtime" + ([#12883](https://github.com/nim-lang/Nim/issues/12883)) +- Fixed "The collect macro does not handle if/case correctly" + ([#12874](https://github.com/nim-lang/Nim/issues/12874)) +- Fixed "allow typed/untyped params in magic procs (even if not in stdlib)" + ([#12911](https://github.com/nim-lang/Nim/issues/12911)) +- Fixed "ARC/newruntime memory corruption" + ([#12899](https://github.com/nim-lang/Nim/issues/12899)) +- Fixed "tasyncclosestall.nim still flaky test: Address already in use" + ([#12919](https://github.com/nim-lang/Nim/issues/12919)) +- Fixed "newruntime and computed goto: variables inside the loop are in generated code uninitialised" + ([#12785](https://github.com/nim-lang/Nim/issues/12785)) +- Fixed "osx: dsymutil needs to be called for debug builds to keep debug info" + ([#12735](https://github.com/nim-lang/Nim/issues/12735)) +- Fixed "codegen ICE with ref objects, gc:destructors" + ([#12826](https://github.com/nim-lang/Nim/issues/12826)) +- Fixed "mutable iterator cannot yield named tuples" + ([#12945](https://github.com/nim-lang/Nim/issues/12945)) +- Fixed "parsecfg stores "\r\n" line breaks just as "\n"" + ([#12970](https://github.com/nim-lang/Nim/issues/12970)) +- Fixed "db_postgres.getValue issues warning when no rows found" + ([#12973](https://github.com/nim-lang/Nim/issues/12973)) +- Fixed "ARC: Unpacking tuple with seq causes segfault" + ([#12989](https://github.com/nim-lang/Nim/issues/12989)) +- Fixed "ARC/newruntime: strutils.join on seq with only empty strings causes segfault" + ([#12965](https://github.com/nim-lang/Nim/issues/12965)) +- Fixed "regression (1.0.4): `{.push exportc.}` wrongly affects generic instantiations, causing codegen errors" + ([#12985](https://github.com/nim-lang/Nim/issues/12985)) +- Fixed "cdt, crash with --gc:arc, works fine with default gc" + ([#12978](https://github.com/nim-lang/Nim/issues/12978)) +- Fixed "ARC: No indexError thrown on out-of-bound seq access, SIGSEGV instead" + ([#12961](https://github.com/nim-lang/Nim/issues/12961)) +- Fixed "ARC/async: Returning in a try-block results in wrong codegen" + ([#12956](https://github.com/nim-lang/Nim/issues/12956)) +- Fixed "asm keyword is generating wrong output C code when --cc:tcc" + ([#12988](https://github.com/nim-lang/Nim/issues/12988)) +- Fixed "Destructor not invoked" + ([#13026](https://github.com/nim-lang/Nim/issues/13026)) +- Fixed "ARC/newruntime: Adding inherited var ref object to seq with base type causes segfault" + ([#12964](https://github.com/nim-lang/Nim/issues/12964)) +- Fixed "Style check error with JS compiler target" + ([#13032](https://github.com/nim-lang/Nim/issues/13032)) +- Fixed "regression(1.0.4): undeclared identifier: 'readLines'; plus another regression and bug" + ([#13013](https://github.com/nim-lang/Nim/issues/13013)) +- Fixed "regression(1.04) `invalid pragma: since` with nim js" + ([#12996](https://github.com/nim-lang/Nim/issues/12996)) +- Fixed "Sink to MemMove optimization in injectdestructors" + ([#13002](https://github.com/nim-lang/Nim/issues/13002)) +- Fixed "--gc:arc: `catch` doesn't work with exception subclassing" + ([#13072](https://github.com/nim-lang/Nim/issues/13072)) +- Fixed "nim c --gc:arc --exceptions:{setjmp,goto} incorrectly handles raise; `nim cpp --gc:arc` is ok" + ([#13070](https://github.com/nim-lang/Nim/issues/13070)) +- Fixed "typetraits feature request - get subtype of a generic type" + ([#6454](https://github.com/nim-lang/Nim/issues/6454)) +- Fixed "CountTable inconsistencies between keys() and len() after setting value to 0" + ([#12813](https://github.com/nim-lang/Nim/issues/12813)) +- Fixed "{.align.} pragma is not applied if there is a generic field" + ([#13122](https://github.com/nim-lang/Nim/issues/13122)) +- Fixed "ARC, finalizer, allow rebinding the same function multiple times" + ([#13112](https://github.com/nim-lang/Nim/issues/13112)) +- Fixed "`nim doc` treats `export localSymbol` incorrectly" + ([#13100](https://github.com/nim-lang/Nim/issues/13100)) +- Fixed "--gc:arc SIGSEGV (double free?)" + ([#13119](https://github.com/nim-lang/Nim/issues/13119)) +- Fixed "codegen bug with arc" + ([#13105](https://github.com/nim-lang/Nim/issues/13105)) +- Fixed "symbols not defined in the grammar" + ([#10665](https://github.com/nim-lang/Nim/issues/10665)) +- Fixed "[JS] Move is not defined" + ([#9674](https://github.com/nim-lang/Nim/issues/9674)) +- Fixed "[TODO] pathutils.`/` can return invalid AbsoluteFile" + ([#13121](https://github.com/nim-lang/Nim/issues/13121)) +- Fixed "regression(1.04) `nim doc main.nim` generates broken html (no css)" + ([#12998](https://github.com/nim-lang/Nim/issues/12998)) +- Fixed "Wrong supportsCopyMem on string in type section" + ([#13095](https://github.com/nim-lang/Nim/issues/13095)) +- Fixed "Arc, finalizer, out of memory" + ([#13157](https://github.com/nim-lang/Nim/issues/13157)) +- Fixed "`--genscript` messes up nimcache and future nim invocations" + ([#13144](https://github.com/nim-lang/Nim/issues/13144)) +- Fixed "--gc:arc with --exceptions:goto for "nim c" generate invalid c code" + ([#13186](https://github.com/nim-lang/Nim/issues/13186)) +- Fixed "[regression] duplicate member `_i1` codegen bug" + ([#13195](https://github.com/nim-lang/Nim/issues/13195)) +- Fixed "RTree investigations with valgrind for --gc:arc" + ([#13110](https://github.com/nim-lang/Nim/issues/13110)) +- Fixed "relativePath("foo", ".") returns wrong path" + ([#13211](https://github.com/nim-lang/Nim/issues/13211)) +- Fixed "asyncftpclient - problem with welcome.msg" + ([#4684](https://github.com/nim-lang/Nim/issues/4684)) +- Fixed "Unclear error message, lowest priority" + ([#13256](https://github.com/nim-lang/Nim/issues/13256)) +- Fixed "Channel messages are corrupted" + ([#13219](https://github.com/nim-lang/Nim/issues/13219)) +- Fixed "Codegen bug with exportc and case objects" + ([#13281](https://github.com/nim-lang/Nim/issues/13281)) +- Fixed "[bugfix] fix #11590: c compiler warnings silently ignored, giving undefined behavior" + ([#11591](https://github.com/nim-lang/Nim/issues/11591)) +- Fixed "[CI] tnetdial flaky test" + ([#13132](https://github.com/nim-lang/Nim/issues/13132)) +- Fixed "Cross-Compiling with -d:mingw fails to locate compiler under OSX" + ([#10717](https://github.com/nim-lang/Nim/issues/10717)) +- Fixed "`nim doc --project` broken with imports below main project file or duplicate names" + ([#13150](https://github.com/nim-lang/Nim/issues/13150)) +- Fixed "regression: isNamedTuple(MyGenericTuple[int]) is false, should be true" + ([#13349](https://github.com/nim-lang/Nim/issues/13349)) +- Fixed "--gc:arc codegen bug copying objects bound to C structs with missing C struct fields" + ([#13269](https://github.com/nim-lang/Nim/issues/13269)) +- Fixed "write requires conversion to string" + ([#13182](https://github.com/nim-lang/Nim/issues/13182)) +- Fixed "Some remarks to stdlib documentation" + ([#13352](https://github.com/nim-lang/Nim/issues/13352)) +- Fixed "a `check` in unittest generated by template doesn't show actual value" + ([#6736](https://github.com/nim-lang/Nim/issues/6736)) +- Fixed "Implicit return with case expression fails with 'var' return." + ([#3339](https://github.com/nim-lang/Nim/issues/3339)) +- Fixed "Segfault with closure on arc" + ([#13314](https://github.com/nim-lang/Nim/issues/13314)) +- Fixed "[Macro] Crash on malformed case statement with multiple else" + ([#13255](https://github.com/nim-lang/Nim/issues/13255)) +- Fixed "regression: `echo 'discard' | nim c -r -` generates a file '-' ; `-` should be treated specially" + ([#13374](https://github.com/nim-lang/Nim/issues/13374)) +- Fixed "on OSX, debugging (w gdb or lldb) a nim program crashes at the 1st call to `execCmdEx`" + ([#9634](https://github.com/nim-lang/Nim/issues/9634)) +- Fixed "Internal error in getTypeDescAux" + ([#13378](https://github.com/nim-lang/Nim/issues/13378)) +- Fixed "gc:arc mode breaks tuple let" + ([#13368](https://github.com/nim-lang/Nim/issues/13368)) +- Fixed "Nim compiler hangs for certain C/C++ compiler errors" + ([#8648](https://github.com/nim-lang/Nim/issues/8648)) +- Fixed "htmlgen does not support `data-*` attributes" + ([#13444](https://github.com/nim-lang/Nim/issues/13444)) +- Fixed "[gc:arc] setLen will cause string not to be null-terminated." + ([#13457](https://github.com/nim-lang/Nim/issues/13457)) +- Fixed "joinPath("", "") is "/" ; should be """ + ([#13455](https://github.com/nim-lang/Nim/issues/13455)) +- Fixed "[CI] flaky test on windows: tests/osproc/texitcode.nim" + ([#13449](https://github.com/nim-lang/Nim/issues/13449)) +- Fixed "Casting to float32 on NimVM is broken" + ([#13479](https://github.com/nim-lang/Nim/issues/13479)) +- Fixed "`--hints:off` doesn't work (doesn't override ~/.config/nim.cfg)" + ([#8312](https://github.com/nim-lang/Nim/issues/8312)) +- Fixed "joinPath("", "") is "/" ; should be """ + ([#13455](https://github.com/nim-lang/Nim/issues/13455)) +- Fixed "tables.values is broken" + ([#13496](https://github.com/nim-lang/Nim/issues/13496)) +- Fixed "global user config can override project specific config" + ([#9405](https://github.com/nim-lang/Nim/issues/9405)) +- Fixed "Non deterministic macros and id consistency problem" + ([#12627](https://github.com/nim-lang/Nim/issues/12627)) +- Fixed "try expression doesn't work with return on expect branch" + ([#13490](https://github.com/nim-lang/Nim/issues/13490)) +- Fixed "CI will break every 4 years on feb 28: times doesn't handle leap years properly" + ([#13543](https://github.com/nim-lang/Nim/issues/13543)) +- Fixed "[minor] `nimgrep --word` doesn't work with operators (eg misses `1 +% 2`)" + ([#13528](https://github.com/nim-lang/Nim/issues/13528)) +- Fixed "`as` is usable as infix operator but its existence and precedence are not documented" + ([#13409](https://github.com/nim-lang/Nim/issues/13409)) +- Fixed "JSON unmarshalling drops seq's items" + ([#13531](https://github.com/nim-lang/Nim/issues/13531)) +- Fixed "os.joinPath returns wrong path when head ends '\' or '/' and tail starts '..'." + ([#13579](https://github.com/nim-lang/Nim/issues/13579)) +- Fixed "Block-local types with the same name lead to bad codegen (sighashes regression)" + ([#5170](https://github.com/nim-lang/Nim/issues/5170)) +- Fixed "tuple codegen error" + ([#12704](https://github.com/nim-lang/Nim/issues/12704)) +- Fixed "newHttpHeaders does not accept repeated headers" + ([#13573](https://github.com/nim-lang/Nim/issues/13573)) +- Fixed "regression: --incremental:on fails on simplest example" + ([#13319](https://github.com/nim-lang/Nim/issues/13319)) +- Fixed "strscan can't get value of last element in format" + ([#13605](https://github.com/nim-lang/Nim/issues/13605)) +- Fixed "hashes_examples crashes with "Bus Error" (unaligned access) on sparc64" + ([#12508](https://github.com/nim-lang/Nim/issues/12508)) +- Fixed "gc:arc bug with re-used `seq[T]`" + ([#13596](https://github.com/nim-lang/Nim/issues/13596)) +- Fixed "`raise CatchableError` is broken with --gc:arc when throwing inside a proc" + ([#13599](https://github.com/nim-lang/Nim/issues/13599)) +- Fixed "cpp --gc:arc --exceptions:goto fails to raise with discard" + ([#13436](https://github.com/nim-lang/Nim/issues/13436)) +- Fixed "terminal doesn't compile with -d:useWinAnsi" + ([#13607](https://github.com/nim-lang/Nim/issues/13607)) +- Fixed "Parsing "sink ptr T" - region needs to be an object type" + ([#12757](https://github.com/nim-lang/Nim/issues/12757)) +- Fixed "gc:arc + threads:on + closures compilation error" + ([#13519](https://github.com/nim-lang/Nim/issues/13519)) +- Fixed "[ARC] segmentation fault" + ([#13240](https://github.com/nim-lang/Nim/issues/13240)) +- Fixed "times.toDateTime buggy on 29th, 30th and 31th of each month" + ([#13558](https://github.com/nim-lang/Nim/issues/13558)) +- Fixed "Deque misbehaves on VM" + ([#13310](https://github.com/nim-lang/Nim/issues/13310)) +- Fixed "Nimscript listFiles should throw exception when path is not found" + ([#12676](https://github.com/nim-lang/Nim/issues/12676)) +- Fixed "koch boot fails if even an empty config.nims is present in ~/.config/nims/ [devel regression]" + ([#13633](https://github.com/nim-lang/Nim/issues/13633)) +- Fixed "nim doc generates lots of false positive LockLevel warnings" + ([#13218](https://github.com/nim-lang/Nim/issues/13218)) +- Fixed "Arrays are passed by copy to iterators, causing crashes, unnecessary allocations and slowdowns" + ([#12747](https://github.com/nim-lang/Nim/issues/12747)) +- Fixed "Range types always uses signed integer as a base type" + ([#13646](https://github.com/nim-lang/Nim/issues/13646)) +- Fixed "Generate c code cannot compile with recent devel version" + ([#13645](https://github.com/nim-lang/Nim/issues/13645)) +- Fixed "[regression] VM: Error: cannot convert -1 to uint64" + ([#13661](https://github.com/nim-lang/Nim/issues/13661)) +- Fixed "Spurious raiseException(Exception) detected" + ([#13654](https://github.com/nim-lang/Nim/issues/13654)) +- Fixed "gc:arc memory leak" + ([#13659](https://github.com/nim-lang/Nim/issues/13659)) +- Fixed "Error: cannot convert -1 to uint (inside tuples)" + ([#13671](https://github.com/nim-lang/Nim/issues/13671)) +- Fixed "strformat issue with --gc:arc" + ([#13622](https://github.com/nim-lang/Nim/issues/13622)) +- Fixed "astToStr doesn't work inside generics" + ([#13524](https://github.com/nim-lang/Nim/issues/13524)) +- Fixed "oswalkdir.walkDirRec wont return folders" + ([#11458](https://github.com/nim-lang/Nim/issues/11458)) +- Fixed "`echo 'echo 1' | nim c -r -` silently gives wrong results (nimBetterRun not updated for stdin)" + ([#13412](https://github.com/nim-lang/Nim/issues/13412)) +- Fixed "gc:arc destroys the global variable accidentally." + ([#13691](https://github.com/nim-lang/Nim/issues/13691)) +- Fixed "[minor] sigmatch errors should be sorted, for reproducible errors" + ([#13538](https://github.com/nim-lang/Nim/issues/13538)) +- Fixed "Exception when converting csize to clong" + ([#13698](https://github.com/nim-lang/Nim/issues/13698)) +- Fixed "ARC: variables are no copied on the thread spawn causing crashes" + ([#13708](https://github.com/nim-lang/Nim/issues/13708)) +- Fixed "Illegal distinct seq causes compiler crash" + ([#13720](https://github.com/nim-lang/Nim/issues/13720)) +- Fixed "cyclic seq definition crashes the compiler" + ([#13715](https://github.com/nim-lang/Nim/issues/13715)) +- Fixed "Iterator with openArray parameter make the argument evaluated many times" + ([#13417](https://github.com/nim-lang/Nim/issues/13417)) +- Fixed "net/asyncnet: Unable to access peer's certificate chain" + ([#13299](https://github.com/nim-lang/Nim/issues/13299)) +- Fixed "Accidentally "SIGSEGV: Illegal storage access" error after arc optimizations (#13325)" + ([#13709](https://github.com/nim-lang/Nim/issues/13709)) +- Fixed "Base64 Regression" + ([#13722](https://github.com/nim-lang/Nim/issues/13722)) +- Fixed "A regression (?) with --gc:arc and repr" + ([#13731](https://github.com/nim-lang/Nim/issues/13731)) +- Fixed "Internal compiler error when using the new variable pragmas" + ([#13737](https://github.com/nim-lang/Nim/issues/13737)) +- Fixed "bool conversion produces vcc 2019 warning at cpp compilation stage" + ([#13744](https://github.com/nim-lang/Nim/issues/13744)) +- Fixed "Compiler "does not detect" a type recursion error in the wrong code, remaining frozen" + ([#13763](https://github.com/nim-lang/Nim/issues/13763)) +- Fixed "[minor] regression: `Foo[0.0] is Foo[-0.0]` is now false" + ([#13730](https://github.com/nim-lang/Nim/issues/13730)) +- Fixed "`nim doc` - only whitespace on first line causes segfault" + ([#13631](https://github.com/nim-lang/Nim/issues/13631)) +- Fixed "hashset regression" + ([#13794](https://github.com/nim-lang/Nim/issues/13794)) +- Fixed "`os.getApplFreebsd` could return incorrect paths in the case of a long path" + ([#13806](https://github.com/nim-lang/Nim/issues/13806)) +- Fixed "Destructors are not inherited" + ([#13810](https://github.com/nim-lang/Nim/issues/13810)) +- Fixed "io.readLines AssertionError on devel" + ([#13829](https://github.com/nim-lang/Nim/issues/13829)) +- Fixed "exceptions:goto accidentally reset the variable during exception handling" + ([#13782](https://github.com/nim-lang/Nim/issues/13782)) 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 new file mode 100644 index 000000000..f8a09a535 --- /dev/null +++ b/changelogs/changelog_X_XX_X.md @@ -0,0 +1,23 @@ +# 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. + +## Language changes + + +## Compiler changes + + +## Tool changes + diff --git a/changelogs/readme.md b/changelogs/readme.md new file mode 100644 index 000000000..3ff1e1b7b --- /dev/null +++ b/changelogs/readme.md @@ -0,0 +1,61 @@ +# Update changelog +After each release, call: +``` +git mv changelog.md changelogs/changelog_0_19_0.md # use correct version +cp changelogs/changelog_X_XX_X.md changelog.md +git add changelog.md +``` + +## Recent changelogs are saved here (with their git history) + +## Older changelogs are stored in https://github.com/nim-lang/website + +## source files: +* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2009-12-21-version-086-released.md +* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2010-03-14-version-088-released.md +* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2010-10-20-version-0810-released.md +* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2011-07-10-version-0812-released.md +* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2012-02-09-version-0814-released.md +* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2012-09-23-version-090-released.md +* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2013-05-20-version-092-released.md +* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2014-04-21-version-094-released.md +* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2014-10-19-version-096-released.md +* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2014-12-29-version-0102-released.md +* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2015-04-30-version-0110-released.md +* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2015-05-04-version-0112-released.md +* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2015-10-27-version-0120-released.md +* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2016-01-18-version-0130-released.md +* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2016-06-07-version-0140-released.md +* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2016-06-09-version-0142-released.md +* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2016-09-30-version-0150-released.md +* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2016-10-23-version-0152-released.md +* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2017-01-08-version-0160-released.md +* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2017-05-17-version-0170-released.md +* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2017-09-07-version-0172-released.md +* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2018-03-01-version-0180-released.md +* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2018-09-26-version-0190-released.md + +## urls: +* https://nim-lang.org/blog/2009/12/21/version-086-released.html +* https://nim-lang.org/blog/2010/03/14/version-088-released.html +* https://nim-lang.org/blog/2010/10/20/version-0810-released.html +* https://nim-lang.org/blog/2011/07/10/version-0812-released.html +* https://nim-lang.org/blog/2012/02/09/version-0814-released.html +* https://nim-lang.org/blog/2012/09/23/version-090-released.html +* https://nim-lang.org/blog/2013/05/20/version-092-released.html +* https://nim-lang.org/blog/2014/04/21/version-094-released.html +* https://nim-lang.org/blog/2014/10/19/version-096-released.html +* https://nim-lang.org/blog/2014/12/29/version-0102-released.html +* https://nim-lang.org/blog/2015/04/30/version-0110-released.html +* https://nim-lang.org/blog/2015/05/04/version-0112-released.html +* https://nim-lang.org/blog/2015/10/27/version-0120-released.html +* https://nim-lang.org/blog/2016/01/18/version-0130-released.html +* https://nim-lang.org/blog/2016/06/07/version-0140-released.html +* https://nim-lang.org/blog/2016/06/09/version-0142-released.html +* https://nim-lang.org/blog/2016/09/30/version-0150-released.html +* https://nim-lang.org/blog/2016/10/23/version-0152-released.html +* https://nim-lang.org/blog/2017/01/08/version-0160-released.html +* https://nim-lang.org/blog/2017/05/17/version-0170-released.html +* https://nim-lang.org/blog/2017/09/07/version-0172-released.html +* https://nim-lang.org/blog/2018/03/01/version-0180-released.html +* https://nim-lang.org/blog/2018/09/26/version-0190-released.html |