From eaca5d90e9063b74750760e43be920f496dd32c2 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Thu, 21 Oct 2021 16:53:15 +0200 Subject: [PATCH] Merge upstream changes Concerns these changes: https://github.com/nim-lang/Nim/compare/727c6378d2464090564dbcd9bc8b9ac648467e38...340b5a1676062aa9bc7f17a2e078eaba96821bf3 Excluded changes are: https://github.com/nim-lang/Nim/pull/18963 https://github.com/nim-lang/Nim/pull/19003 https://github.com/nim-lang/Nim/pull/19043 https://github.com/nim-lang/Nim/pull/19055 https://github.com/nim-lang/Nim/pull/19053 https://github.com/nim-lang/Nim/pull/19064 https://github.com/nim-lang/Nim/pull/18642 https://github.com/nim-lang/Nim/pull/19062 https://github.com/nim-lang/Nim/pull/19082 https://github.com/nim-lang/Nim/pull/19090 https://github.com/nim-lang/Nim/pull/19077 https://github.com/nim-lang/Nim/pull/19021 https://github.com/nim-lang/Nim/pull/19100 https://github.com/nim-lang/Nim/pull/19102 https://github.com/nim-lang/Nim/pull/19111 https://github.com/nim-lang/Nim/pull/19115 https://github.com/nim-lang/Nim/pull/19133 https://github.com/nim-lang/Nim/pull/19142 https://github.com/nim-lang/Nim/pull/19158 https://github.com/nim-lang/Nim/pull/19129 https://github.com/nim-lang/Nim/pull/19137 https://github.com/nim-lang/Nim/pull/19168 https://github.com/nim-lang/Nim/pull/19156 https://github.com/nim-lang/Nim/pull/19147 https://github.com/nim-lang/Nim/pull/19180 https://github.com/nim-lang/Nim/pull/19183 https://github.com/nim-lang/Nim/pull/19182 https://github.com/nim-lang/Nim/pull/19187 https://github.com/nim-lang/Nim/pull/19179 https://github.com/nim-lang/Nim/pull/19209 https://github.com/nim-lang/Nim/pull/19210 https://github.com/nim-lang/Nim/pull/19207 https://github.com/nim-lang/Nim/pull/19219 https://github.com/nim-lang/Nim/pull/19195 https://github.com/nim-lang/Nim/pull/19212 https://github.com/nim-lang/Nim/pull/19134 https://github.com/nim-lang/Nim/pull/19235 https://github.com/nim-lang/Nim/pull/19252 https://github.com/nim-lang/Nim/pull/19196 https://github.com/nim-lang/Nim/pull/19295 https://github.com/nim-lang/Nim/pull/19301 https://github.com/nim-lang/Nim/pull/19181 https://github.com/nim-lang/Nim/pull/17223 https://github.com/nim-lang/Nim/pull/19370 https://github.com/nim-lang/Nim/pull/19385 https://github.com/nim-lang/Nim/pull/19307 https://github.com/nim-lang/Nim/pull/19394 https://github.com/nim-lang/Nim/pull/19399 https://github.com/nim-lang/Nim/pull/19390 https://github.com/nim-lang/Nim/pull/19407 https://github.com/nim-lang/Nim/pull/19419 https://github.com/nim-lang/Nim/pull/19421 https://github.com/nim-lang/Nim/pull/19363 https://github.com/nim-lang/Nim/pull/19406 https://github.com/nim-lang/Nim/pull/19431 https://github.com/nim-lang/Nim/pull/19455 https://github.com/nim-lang/Nim/pull/19461 https://github.com/nim-lang/Nim/commit/cb894c7094fb49014f85815a9dafc38b5dda743e https://github.com/nim-lang/Nim/pull/19462 https://github.com/nim-lang/Nim/pull/19442 https://github.com/nim-lang/Nim/pull/19437 https://github.com/nim-lang/Nim/pull/19433 https://github.com/nim-lang/Nim/pull/19512 https://github.com/nim-lang/Nim/pull/19487 https://github.com/nim-lang/Nim/pull/19543 Excluded changes include major changes which require more consideration and changes which don't apply to the current code anymore but could be worth porting over still. Excluded changes which only change the identifier casing in tests or only concern code removed in nimskull aren't listed. Begin commit listing: use two underscores for easy demangling [backport:1.6] (#19028) Add Elbrus 2000 architecture (#19024) * Add Elbrus 2000 architecture * Add e2k to niminst * Update compiler/installer.ini Co-authored-by: Andreas Rumpf remove exception (#18906) allow converting static vars to `openArray` (#19035) When assigning constant output to a seq, and then passing that static seq to other functions that take `openArray`, the compiler may end up producing errors, as it does not know how to convert `static[seq[T]]` to `openArray[T]`. By ignoring the `static` wrapper on the type for the purpose of determining data memory location and length, this gets resolved cleanly. Unfortunately, it is relatively tricky to come up with a minimal example, as there are followup problems from the failing conversion, e.g., this may lead to `internal error: inconsistent environment type`, instead of the relevant `openArrayLoc` error message. use the correct header for TIOCGWINSZ on Solaris (#19037) Minor update to terminal docs (#19056) * Update terminal.nim - Added some extra docs to cursorUp/Down/Forward/Backward - I was able to use hideCursor and showCursor without adding stdout, removed the parameter - Added docs to terminalHeight()* and terminalWidth()* * Update lib/pure/terminal.nim Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> * Update lib/pure/terminal.nim Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> * Added back f: file to cursor movement * Removed unnecessary comments Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> fix a tiny formating issue in doc/destructors.rst (#19058) fix a tiny code snippet formatting issue in `doc/constructors.rst`, again (#19065) Fix nimIdentNormalize, fixes #19067 (#19068) * Make nimIdentNormalize return "" when passed ""; fixes #19067 Fixes #19067 * Add tests for nimIdentNormalize fix #18971 (#19070) [backport:1.6] since the example code return value from global variable, instead of first argument, the `n.len` is 1 which causes compiler crashes. fixes #19000 (#19032) * fixes #19000 * progress fix #18410 (Errors initializing an object of RootObj with the C++ backend) [backport] (#18836) * fix #18410 * one line comment * typo * typo * cover cpp update numbers of lifetime-tracking hooks in doc/destructors.rst (#19088) bootstrapping Nim compiler with `cpp --gc:orc` (#19087) libs/impore/re: Add note about the requirement of `matches` to be pre-allocated (#19081) Add few runnableExamples for `findBounds` for clarity. Fixes https://github.com/nim-lang/Nim/issues/18775 Add test for issue 15435 (#19079) * Add test for issue 15435 Closes https://github.com/nim-lang/Nim/issues/15435. * Specify bug # in comment Addresses https://github.com/nim-lang/Nim/pull/19079#discussion_r740279547 manual: Document the use of `static` as a proc call (#19084) * manual: Document the use of `static` as a proc call Also adds tests. Fixes https://github.com/nim-lang/Nim/issues/16987 . * Update doc/manual.rst Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> * Use the "bug #NNNN" comment syntax for consistency Ref: https://nim-lang.github.io/Nim/contributing.html#writing-tests-stdlib > Always refer to a GitHub issue using the following exact syntax: bug for tooling. * manual: Undocument usage of foo.static foo.static and foo.static() are not expected to work. Ref: https://github.com/nim-lang/Nim/pull/19084/files#r741203578 Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> manual: Document that comma propagates the default values of parameters (#19080) * manual: Document that comma propagates the default values of parameters Fixes https://github.com/nim-lang/Nim/issues/15949. * Use the "bug #NNNN" comment syntax for consistency Ref: https://nim-lang.github.io/Nim/contributing.html#writing-tests-stdlib > Always refer to a GitHub issue using the following exact syntax: bug for tooling. fixes #19011 [backport:1.6] (#19114) Add deprecation pragmas in lib/deprecated/pure (#19113) Deprecate `std/sharedlist` and `std/sharedtables` (#19112) fix nimindexterm in rst2tex/doc2tex [backport] (#19106) * fix nimindexterm (rst2tex/doc2tex) [backport] * Add support for indexing in rst Call {.cursor.} a pragma. (#19116) * Call {.cursor.} a pragma. Its hard to find .curser annotation while googling because all other things like it are called pragmas. See https://nim-lang.org/docs/manual.html#pragmas Also the . in front of the name makes it hard to find and search for. Can we just call it cursor pragma? * Small fix for comment. Remove tlsEmulation enabled from Windows + GCC config (#19119) [backport:1.6] This flag has a very significant performance impact on programs compiled with --threads:on. It is also apparently not needed anymore for standard circumstances. Can we remove the config? See https://github.com/nim-lang/Nim/issues/18146#issuecomment-876802676 for discussion and perf impact. [backport:1.6] Add security tip for setCookie (#19117) * Add security tip for setCookie * Update lib/pure/cookies.nim Co-authored-by: Dominik Picheta * Update lib/pure/cookies.nim Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> Co-authored-by: Andreas Rumpf Co-authored-by: Dominik Picheta Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> correct cookie docs (#19122) refactoring: orc can use getThreadId() (#19123) * refactoring: orc can use getThreadId() * progress fixed colorNames sorting mistake (#19125) [backport] update manual (#19130) [backport] Merge file size fields correctly on Windows (#19141) * Merge file size fields correctly on Windows Merge file size fields correctly on Windows - Merge the two 32-bit file size fields from `BY_HANDLE_FILE_INFORMATION` correctly in `rawToFormalFileInfo`. - Fixes #19135 * Update os.nim Fix punycode.decode function (#19136) * Refactor: rename proc to func * Fix punycode.decode function This function could only properly decode punycodes containing a single encoded unicode character. As soon as there was more than one punycode character group to decode it produced invalid output - the number of characters was correct, but their position was not. * Update tpunycode.nim Co-authored-by: Clay Sweetser Fix undeclared 'SYS_getrandom' on emscripten (#19144) wrong spaces (3 => 2) (#19145) `caseStmtMacros` no longer experimental, experimental manual refactor (#19173) * `caseStmtMacros` no longer experimental, experimental manual refactor * Update doc/manual.rst * apply review suggestions * apply review Co-authored-by: Andreas Rumpf fix inline syntax highlighting in system.nim (#19184) swap port to correct port order (#19177) Co-authored-by: Jaremy Creechley feat: TLS-ALPN wrappers for OpenSSL (#19202) Co-authored-by: Iced Quinn misc bugfixes [backport:1.2] (#19203) treat do with pragmas but no parens as proc (#19191) fixes #19188 [format minor] remove unnecessary spaces (#19216) Making TCC work again on Windows --cpu:amd64 - fix #16326 (#19221) * fix #16326 * removing comments fixes a converter handling regression that caused private converters to leak into client modules; fixes #19213; [backport:1.6] (#19229) Add support for LoongArch (#19223) * Add support for LoongArch * Update compiler/installer.ini Co-authored-by: Andreas Rumpf remove `std/sharedstrings` (#19228) * remove std/sharedstrings it has been broken since 0.18.0 * rephrase the changelog entry add comments to spawn and pinnedSpawn (#19230) `spawn` uses `nimSpawn3` internally and `pinnedSpawn` uses `nimSpawn4` internally. I comment it in order to help contributors get the gist of its functionality. fixes an old ARC bug: the produced copy/sink operations don't copy the hidden type field for objects with enabled inheritance; fixes #19205 [backport:1.6] (#19232) nimRawSetjmp: support Windows (#19197) * nimRawSetjmp: support Windows Using `_setjmp()` directly is required to avoid some rare (but very annoying) exception-related stack corruption leading to segfaults on Windows, with Mingw-w64 and SEH. More details: https://github.com/status-im/nimbus-eth2/issues/3121 Also add "nimBuiltinSetjmp" - mostly for benchmarking. * fix for Apple's Clang++ Revert "swap port to correct port order (#19177)" (#19234) This reverts commit 0d0c249074d6a1041de16108dc247396efef5513. move toDeque to after addLast (#19233) [backport:1.0] Changes the order of procs definitions in order to avoid calling an undefined proc. let Nim support Nimble 0.14 with lock-file support [backport:1.6] (#19236) nimc.rst: fix table markup (#19239) Various std net improvements (#19132) * Variant of that works with raw IpAddresses. - Add doc tests for new net proc's. - Aadd recvFrom impl - Add recvFrom impl -- tweak handling data var - Update lib/pure/net.nim Co-authored-by: Dominik Picheta - cleaning up sendTo args - remove extra connect test - cleaning up sendTo args - fix inet_ntop test - fix test failing - byte len * fix test failing - byte len * debugging odd windows build failure * debugging odd windows build failure * more experiments to figure out the windows failure * try manual assigment on InAddr Co-authored-by: Jaremy Creechley fix bug #14468 zero-width split (#19248) basicopt.txt: Unify the format (#19251) fix: fixes bug in CVerifyPeerUseEnvVars (#19247) Previously CVerifyPeerUseEnvVars was not being passed into scanSslCertificates, which meant that we weren't scanning additional certificate locations given via the SSL_CERT_FILE and SSL_CERT_DIR environment variables suggestion to respect typedarray type (#19257) * suggestion to respect typedarray * Update jssys.nim Co-authored-by: Sven Keller fix #19244 - solves the problem of the InAddr object constructor in Windows. (#19259) * Update winlean.nim * Update tnet_ll.nim Fixed typo in manual.rst unsafeAssign->uncheckedAssign. Fixes part 1 of #19266 (#19267) use uppercase "type" for Proxy-Authorization header (#19273) Some servers will reject authorization requests with a lowercase "basic" type. Changing to "Basic" seems to solve these issues. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Proxy-Authorization Update colors.nim (#19274) * Update colors.nim Added `lightgray` alias to `lightgrey` and `...grey`aliases for the rest of the gray colors. Added color `rebeccapurple`. Fixed the incorrect values for the `PaleVioletRed` and `MediumPurple` colors. This module should now be matching the CSS colors. I used the seq[tuple] syntax for defining the names. * Document colors changes. Extract runnables that specify `doccmd` (#19275) [backport:1.6] Fix build on FreeBSD/powerpc (#19282) It's currently misdetected as powerpc64. Fix #19107 (#19286) [backport] fixes grammar typos [backport] (#19289) fix 19292 (#19293) Fix #19297 - fixing broken list after adding empty list (#19299) * Update lists.nim * Update tlists.nim * removed check `if b.tail != nil` The tail of the list being null it is still possible to retrieve its end by going through all nodes from the head. So checking for null from `b.tail` is unnecessary. However, setting `a.tail = b.tail` only if `a.head != nil`, so you don't break a good list with an already broken one. fixes #16617 [backport] (#19300) Update JS and nimscript import tests (#19306) * add new modules, except experimental ones * remove deprecated modules mersenne and sharedlist * better describe why some modules fail and some modules don't add compile time option for POSIX sigwait on Illumos/Solaris (#19296) * add compile time option for POSIX sigwait on Illumos/Solaris * fix link to documentation of `sigwait` on Illumos/Solaris [docs] clarify the raised exception (#19308) * [docs] clarify the raised exception Lest developers wanna know what the exception is. * Apply suggestions from @konsumlamm Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> docs: Fix typo in tut1.rst (#19309) Fix #19314 - fixing broken `DoublyLinkedList` after adding empty `DoublyLinkedList` (#19315) [backport] * Update lists.nim * Update tlists.nim fixed typos (#19316) devel: style fix (#19318) this allows "--styleCheck:usages --styleCheck:error" docs: Fix typo in tut1.rst (#19324) correct the comments (#19322) --expandArc ``` var a b a = matrix(5, 5, 1.0) b = matrix(5, 5, 2.0) `=sink`(b, - let blitTmp = b wasMoved(b) blitTmp + a) `=destroy`(b) `=destroy`(a) ``` add std/private/win_getsysteminfo; refactor the usage of `GetSystemInfo` (#19310) * add std/private/win_getsysteminfo * import at the top level * wrappers follow nep1 too * follow review comment Update net.nim (#19327) [backport] Fix #19038 - making the Nim compiler work again on Windows XP (#19331) * Update osenv.nim * Update win_setenv.nim * Update lib/pure/includes/osenv.nim * Update lib/pure/includes/osenv.nim * fixing cstring Co-authored-by: Andreas Rumpf fix nim-lang#19343 (#19344) [backport] Ensure HttpClient onProgress is called once per second Ensure that reported speed is accurate stylecheck usages part two: stdlib cleanup (#19338) * stylecheck usages part two: stdlib cleanup typeinfo.nim: importCompilerProc => importcompilerproc nre.nim: newLineFlags => newlineFlags system.nim: JSRoot => JsRoot ref #19319 * prefer importCompilerProc added filemode docs (#19346) Fix `remove` on last node of singly-linked list [backport:1.6] (#19353) fix stylecheck error with asyncdispatch (#19350) * stylecheck usages part two: stdlib cleanup typeinfo.nim: importCompilerProc => importcompilerproc nre.nim: newLineFlags => newlineFlags system.nim: JSRoot => JsRoot ref #19319 * prefer importCompilerProc * fix stylecheck error with asyncdispatch it is a partial regression since #12842 * add tests * don't use echo in tests remove spaces between an identifier and a star (#19355) It makes search easier by searching `+`* instead of `+` which filter lots of unexported versions. Follow https://github.com/nim-lang/Nim/pull/18681 bitsets.nim: cleanup (#19361) make rst thread safe (#19369) split for the convenience of review docs: Mention `import foo {.all.}` syntax (#19377) Mention the `import foo {.all.}` syntax in the manual, with a caveat about private imports. Also link to the experimental importutils module. Co-authored-by: adigitoleo update copyright year (#19381) docs: Fix broken cross references to `rfind` in strutils (#19382) [backport] Fixes three broken cross references to `rfind` in strutils. Breakage due to signature changes of the `rfind` methods. Co-authored-by: adigitoleo move type operation section and remove deepcopy document (#19389) ref #19173; because deepcopy is not fit for ORC/ARC which was used for spawn and spawn will be removed from compiler deprecate unsafeAddr; extend addr (#19373) * deprecate unsafeAddr; extend addr addr is now available for all addressable locations, unsafeAddr is deprecated and become an alias for addr * follow @Vindaar's advice * change the signature of addr * unsafeAddr => addr (stdlib) * Update changelog.md * unsafeAddr => addr (tests) * Revert "unsafeAddr => addr (stdlib)" This reverts commit ab83c99c507048a8396e636bf22d55fdd84d7d1c. * doc changes; thanks to @konsumlamm Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> improve changelog a bit (#19400) mangle names in nimbase.h using cppDefine (#19395) [backport] mangle names in nimbase.h fix comments Optimize lent in JS [backport:1.6] (#19393) * Optimize lent in JS [backport:1.6] * addr on lent doesn't work anymore, don't use it * use unsafeAddr in test again for older versions update deprecated example (#19415) `toNimIdent` proc is deprecated, so I replaced it with `ident` proc Improve Zshell completion (#19354) fix stricteffects (nimsuggest/sexp) (#19405) * fix stricteffects (nimsuggest/sexp) * Update tstrict_effects3.nim * Update tests/effects/tstrict_effects3.nim suppress deprecated warnings (#19408) * suppress deprecated warnings once bump version to 1.7.3 enable deprecated messages * deprecate later add an example to setControlCHook (#19416) * add an example to setControlCHook * [skip CI] format example for setControlCHook Co-authored-by: Nathan Blaxall fix term rewriting with sideeffect (#19410) * fix term rewriting with sideeffect fix #6217 * add tests * Update tests/template/template_various.nim Resolve cross file resolution errors in atomics (#19422) [backport:1.6] * Resolve call undeclared routine testAndSet * Fix undeclared field atomicType Fix #11923 (#19427) * Apply commit https://github.com/nim-lang/Nim/commit/5da931fe811717a45f2dd272ea6281979c3e8f0b that was never merged (was part of a bigger PR). Should fix issue #11932 * add a generic object for custom pragma os: faster getFileSize (#19438) Use "stat" rather than "open", "seek", and "close" system calls. The Windows implementation remains the same. bugfix: varargs count as open arrays (#19447) update outdated link (#19465) Ref https://github.com/nim-lang/Nim/issues/19463 Update jsfetch with latest API and fix missing bindings (#19473) * Update with latest API and fix missing bindings remove deprecated `Body` remove implicit `cstring` convs add `Headers` to `FetchOptions` add `Request` init proc which takes `FetchOptions` * Update lib/std/jsfetch.nim Co-authored-by: Juan Carlos * Update lib/std/jsfetch.nim Co-authored-by: Juan Carlos * remove experimental flag Co-authored-by: Juan Carlos No longer segfault when using a typeclass with a self referencing type (#19467) Clonkk fix2 11923 (#19451) * fix nnkBracketExpr not compiling for getImpl on customPragmaNode * fix test import * fix alias not working with hasCustomPragmas fix parseEnum cannot parse enum with const fields (#19466) fix #19463 Add compilers and hints to default nim.cfg (#18424) don't use a temp for addr [backport: 1.6] (#19503) * don't use a temp for addr fix #19497 * Update compiler/ccgcalls.nim Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> * add a test Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> fixes #19404 by protecting the memory we borrow from. this replaces crashes with minor memory leaks which seems to be acceptable. In the longer run we need a better VM that didn't grow hacks over a decade. (#19515) Co-authored-by: flywind Remove backslash in glob pattern (#19524) use OrderedTable instead of OrderedTableRef for mimedb (#19522) * use OrderedTable instead of OrderedTableRef for mimedb Signed-off-by: David Krause * added changelog entry for mimedb change Signed-off-by: David Krause Remove Deprecated oids.oidsToString (#19519) * Remove deprecated oids.oidToString * Remove deprecated oids.oidToString Remove deprecated math.c_frexp (#19518) * Remove Deprecated math proc * Remove Deprecated math proc * Remove Deprecated math proc [testcase] genSym fails to make unique identifier for ref object types (#19506) close #15118 Documentation: Fix word usage (#19529) Update chcks.nim (#19540) keep casing of noinit and noreturn pragmas consistently documented (#19535) compile pragma: cache the result sooner (#19554) extccomp.addExternalFileToCompile() relies on hashes to decide whether an external C file needs recompilation or not. Due to short-circuit evaluation of boolean expressions, the procedure that generates a corresponding hash file is not called the first time an external file is compiled, so an avoidable recompilation is triggered the next build. This patch fixes that by moving the proc call with a desired side effect from its boolean expression, so it's executed unconditionally. --- changelog.md | 61 + changelogs/changelog_1_4_0.md | 2 +- compiler/ast/ast_types.nim | 2 +- compiler/ast/parser.nim | 20 +- compiler/ast/types.nim | 3 + compiler/ast/wordrecg.nim | 2 +- compiler/backend/ccgcalls.nim | 6 +- compiler/backend/ccgexprs.nim | 8 + compiler/backend/ccgstmts.nim | 13 +- compiler/backend/ccgtypes.nim | 4 +- compiler/backend/cgen.nim | 3 +- compiler/backend/extccomp.nim | 4 +- compiler/backend/jsgen.nim | 49 +- compiler/front/in_options.nim | 2 +- compiler/front/options.nim | 2 +- compiler/modules/importer.nim | 6 +- compiler/sem/isolation_check.nim | 2 +- compiler/sem/liftdestructors.nim | 10 + compiler/sem/optimizer.nim | 4 +- compiler/sem/parampatterns.nim | 7 +- compiler/sem/semfold.nim | 8 +- compiler/sem/semmagic.nim | 4 +- compiler/sem/semobjconstr.nim | 12 +- compiler/sem/semstmts.nim | 7 +- compiler/sem/semtempl.nim | 3 +- compiler/sem/sigmatch.nim | 3 +- compiler/sem/typeallowed.nim | 4 +- compiler/sem/varpartitions.nim | 2 +- compiler/utils/bitsets.nim | 35 +- compiler/utils/platform.nim | 7 +- compiler/vm/vm.nim | 21 +- config/config.nims | 5 + config/nim.cfg | 20 +- config/nimdoc.tex.cfg | 12 +- copying.txt | 2 +- doc/backends.rst | 23 +- doc/basicopt.txt | 4 +- doc/destructors.rst | 20 +- doc/grammar.txt | 6 +- doc/intern.rst | 2 +- doc/lib.rst | 8 +- doc/manual.rst | 474 +++- doc/manual_experimental.rst | 2401 ++++++++--------- doc/nimc.rst | 16 + doc/tut1.rst | 4 +- lib/core/macros.nim | 41 +- lib/deprecated/pure/LockFreeHash.nim | 6 +- lib/deprecated/pure/events.nim | 2 + lib/deprecated/pure/ospaths.nim | 5 +- lib/deprecated/pure/securehash.nim | 5 +- lib/deprecated/pure/sharedstrings.nim | 152 -- lib/experimental/sexp.nim | 2 +- lib/impure/nre.nim | 2 +- lib/impure/re.nim | 45 +- lib/js/jsffi.nim | 38 +- lib/packages/docutils/rst.nim | 6 +- lib/packages/docutils/rstgen.nim | 2 +- lib/posix/posix.nim | 11 +- lib/posix/termios.nim | 7 +- lib/pure/base64.nim | 4 +- lib/pure/collections/deques.nim | 28 +- lib/pure/collections/lists.nim | 26 +- lib/pure/collections/sharedlist.nim | 2 + lib/pure/collections/sharedtables.nim | 2 + lib/pure/collections/tables.nim | 1 - lib/pure/colors.nim | 307 ++- lib/pure/concurrency/atomics.nim | 17 +- lib/pure/concurrency/cpuinfo.nim | 24 +- lib/pure/concurrency/threadpool.nim | 6 +- lib/pure/cookies.nim | 2 + lib/pure/hashes.nim | 2 +- lib/pure/httpclient.nim | 4 +- lib/pure/includes/osenv.nim | 5 +- lib/pure/math.nim | 5 - lib/pure/md5.nim | 4 +- lib/pure/mimetypes.nim | 4 +- lib/pure/net.nim | 66 +- lib/pure/oids.nim | 5 - lib/pure/os.nim | 23 +- lib/pure/punycode.nim | 31 +- lib/pure/reservedmem.nim | 19 +- lib/pure/strformat.nim | 12 +- lib/pure/strutils.nim | 11 +- lib/pure/terminal.nim | 14 + lib/pure/uri.nim | 8 +- lib/std/enumutils.nim | 9 +- lib/std/jsfetch.nim | 46 +- lib/std/private/win_getsysteminfo.nim | 15 + lib/std/private/win_setenv.nim | 48 +- lib/std/sha1.nim | 4 +- lib/std/sysrand.nim | 2 +- lib/system.nim | 34 +- lib/system/ansi_c.nim | 46 +- lib/system/atomics.nim | 10 +- lib/system/chcks.nim | 2 +- lib/system/io.nim | 23 +- lib/system/jssys.nim | 28 +- lib/system/memalloc.nim | 6 + lib/system/orc.nim | 7 +- lib/system/platforms.nim | 6 +- lib/system/threadids.nim | 103 + lib/system/threadlocalstorage.nim | 3 - lib/system/threads.nim | 95 +- lib/system_overview.rst | 1 + lib/windows/winlean.nim | 2 +- lib/wrappers/openssl.nim | 14 + nimpretty/nimpretty.nim | 4 +- testament/testament.nim | 1 - tests/arc/t18971.nim | 10 + tests/arc/tarc_orc.nim | 22 + tests/arc/tarcmisc.nim | 15 + tests/arc/tconst_to_sink.nim | 3 +- tests/arc/tcustomtrace.nim | 2 +- tests/arc/thard_alignment.nim | 2 +- tests/ccgbugs/tmangle.nim | 16 + tests/ccgbugs/tnoalias.nim | 2 +- tests/compiles/t8630.nim | 2 +- tests/concepts/tconcepts_issues.nim | 4 +- tests/converter/mdontleak.nim | 3 + tests/converter/tdontleak.nim | 10 + tests/cpp/torc.nim | 15 + tests/destructor/t12037.nim | 6 +- tests/destructor/tarray_indexing.nim | 2 +- tests/destructor/tcustomseqs.nim | 2 +- tests/destructor/tcustomstrings.nim | 2 +- .../destructor/tuse_result_prevents_sinks.nim | 2 +- tests/errmsgs/t10594.nim | 2 +- tests/errmsgs/tnon_concrete_cast.nim | 2 +- tests/exception/texceptions.nim | 6 +- tests/exception/texceptions2.nim | 130 + tests/generics/tgenerics_issues.nim | 12 + tests/js/tfieldchecks.nim | 2 +- tests/js/tlent.nim | 33 + tests/js/tstdlib_imports.nim | 43 +- tests/lent/tbasic_lent_check.nim | 20 +- tests/macros/tcasestmtmacro.nim | 2 - tests/macros/tmacros_various.nim | 60 + tests/misc/taddr.nim | 2 +- tests/overload/t8829.nim | 4 +- tests/overload/tstatic_with_converter.nim | 2 +- tests/parser/tdo.nim | 19 +- tests/pragmas/tcustom_pragma.nim | 16 + tests/proc/t15949.nim | 20 + tests/sets/t15435.nim | 29 + tests/stdlib/concurrency/atomicSample.nim | 9 + tests/stdlib/concurrency/tatomic_import.nim | 11 + tests/stdlib/thttpclient_ssl.nim | 16 + tests/stdlib/tlists.nim | 37 + tests/stdlib/tmacros.nim | 20 + tests/stdlib/tmath.nim | 6 - tests/stdlib/tmemory.nim | 2 +- tests/stdlib/tmimetypes.nim | 2 + tests/stdlib/tnet_ll.nim | 94 +- tests/stdlib/tpunycode.nim | 202 +- tests/stdlib/tre.nim | 6 + tests/stdlib/tsqlitebindatas.nim | 4 +- tests/stdlib/tstrutils.nim | 18 + tests/strictnotnil/tnilcheck.nim | 2 +- tests/stylecheck/taccept.nim | 15 + tests/stylecheck/treject.nim | 17 + tests/system/tdollars.nim | 7 + tests/system/tostring.nim | 2 +- tests/system/tstatic_callable.nim | 12 + tests/system/tstatic_callable_error.nim | 14 + tests/template/t6217.nim | 19 + tests/test_nimscript.nims | 50 +- tests/types/tlent_var.nim | 2 +- tools/koch/koch.nim | 5 +- tools/koch/kochdocs.nim | 6 + tools/nim.zsh-completion | 256 +- tools/niminst/buildsh.nimf | 10 +- tools/niminst/makefile.nimf | 6 + 172 files changed, 3643 insertions(+), 2509 deletions(-) delete mode 100644 lib/deprecated/pure/sharedstrings.nim create mode 100644 lib/std/private/win_getsysteminfo.nim create mode 100644 lib/system/threadids.nim create mode 100644 tests/arc/t18971.nim create mode 100644 tests/arc/tarc_orc.nim create mode 100644 tests/ccgbugs/tmangle.nim create mode 100644 tests/converter/mdontleak.nim create mode 100644 tests/converter/tdontleak.nim create mode 100644 tests/cpp/torc.nim create mode 100644 tests/exception/texceptions2.nim create mode 100644 tests/js/tlent.nim create mode 100644 tests/proc/t15949.nim create mode 100644 tests/sets/t15435.nim create mode 100644 tests/stdlib/concurrency/atomicSample.nim create mode 100644 tests/stdlib/concurrency/tatomic_import.nim create mode 100644 tests/stylecheck/taccept.nim create mode 100644 tests/stylecheck/treject.nim create mode 100644 tests/system/tstatic_callable.nim create mode 100644 tests/system/tstatic_callable_error.nim create mode 100644 tests/template/t6217.nim diff --git a/changelog.md b/changelog.md index fbda7058288..0257c28dba4 100644 --- a/changelog.md +++ b/changelog.md @@ -5,13 +5,68 @@ +- `std/sharedstrings` module is removed. +- Constants `colors.colPaleVioletRed` and `colors.colMediumPurple` changed to match the CSS color standard. + +- `addr` is now available for all addressable locations, `unsafeAddr` is deprecated and +becomes an alias for `addr`. + ## Standard library additions and changes +- `macros.parseExpr` and `macros.parseStmt` now accept an optional + filename argument for more informative errors. +- Module `colors` expanded with missing colors from the CSS color standard. +- Fixed `lists.SinglyLinkedList` being broken after removing the last node ([#19353](https://github.com/nim-lang/Nim/pull/19353)). + +- `std/smtp` sends `ehlo` first. If the mail server does not understand, it sends `helo` as a fallback. + +- Added `IsoWeekRange`, a range type to represent the number of weeks in an ISO week-based year. +- Added `IsoYear`, a distinct int type to prevent bugs from confusing the week-based year and the regular year. +- Added `initDateTime` in `times` to create a datetime from a weekday, and ISO 8601 week number and week-based year. +- Added `getIsoWeekAndYear` in `times` to get an ISO week number along with the corresponding ISO week-based year from a datetime. +- Added `getIsoWeeksInYear` in `times` to return the number of weeks in an ISO week-based year. + +- Added `std/oserrors` for OS error reporting. Added `std/envvars` for environment variables handling. +- Removed deprecated `oids.oidToString`. + + +- Changed mimedb to use an `OrderedTable` instead of `OrderedTableRef`, to use it in a const. + +- Removed deprecated `math.c_frexp`. ## Language changes + ```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 + ``` +- [Case statement macros](manual.html#macros-case-statement-macros) are no longer experimental, + meaning you no longer need to enable the experimental switch `caseStmtMacros` to use them. ## Compiler changes @@ -23,3 +78,9 @@ +- Nim now supports Nimble version 0.14 which added support for lock-files. This is done by + a simple configuration change setting that you can do yourself too. In `$nim/config/nim.cfg` + replace `pkgs` by `pkgs2`. + +- There is a new switch `--nimMainPrefix:prefix` to influence the `NimMain` that the + compiler produces. This is particularly useful for generating static libraries. diff --git a/changelogs/changelog_1_4_0.md b/changelogs/changelog_1_4_0.md index 091048ad196..77f66ffdeba 100644 --- a/changelogs/changelog_1_4_0.md +++ b/changelogs/changelog_1_4_0.md @@ -282,7 +282,7 @@ - Removed the deprecated `asyncdispatch.newAsyncNativeSocket`. - Removed the deprecated `dom.releaseEvents` and `dom.captureEvents`. -- Removed `sharedlists.initSharedList`, was deprecated and produces undefined behaviour. +- 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) diff --git a/compiler/ast/ast_types.nim b/compiler/ast/ast_types.nim index 95c27dac4b6..0b953ecedd1 100644 --- a/compiler/ast/ast_types.nim +++ b/compiler/ast/ast_types.nim @@ -688,7 +688,7 @@ type mSwap, mIsNil, mArrToSeq, mNewString, mNewStringOfCap, mParseBiggestFloat, mMove, mWasMoved, mDestroy, mTrace, - mDefault, mUnown, mFinished, mIsolate, mAccessEnv, mReset, + mDefault, mUnown, mFinished, mIsolate, mAccessEnv, mAccessTypeField, mReset, mArray, mOpenArray, mRange, mSet, mSeq, mVarargs, mRef, mPtr, mVar, mDistinct, mVoid, mTuple, mOrdinal, mIterableType, diff --git a/compiler/ast/parser.nim b/compiler/ast/parser.nim index 044aa287d59..cbb50683b87 100644 --- a/compiler/ast/parser.nim +++ b/compiler/ast/parser.nim @@ -605,10 +605,10 @@ proc parsePar(p: var Parser): PNode = #| | 'finally' | 'except' | 'for' | 'block' | 'const' | 'let' #| | 'when' | 'var' | 'mixin' #| par = '(' optInd - #| ( &parKeyw (ifExpr \ complexOrSimpleStmt) ^+ ';' - #| | ';' (ifExpr \ complexOrSimpleStmt) ^+ ';' + #| ( &parKeyw (ifExpr / complexOrSimpleStmt) ^+ ';' + #| | ';' (ifExpr / complexOrSimpleStmt) ^+ ';' #| | pragmaStmt - #| | simpleExpr ( ('=' expr (';' (ifExpr \ complexOrSimpleStmt) ^+ ';' )? ) + #| | simpleExpr ( ('=' expr (';' (ifExpr / complexOrSimpleStmt) ^+ ';' )? ) #| | (':' expr (',' exprColonEqExpr ^+ ',' )? ) ) ) #| optPar ')' # @@ -1136,11 +1136,14 @@ proc optPragmas(p: var Parser): PNode = proc parseDoBlock(p: var Parser; info: TLineInfo): PNode = #| doBlock = 'do' paramListArrow pragma? colcom stmt - let params = parseParamList(p, retColon=false) + var params = parseParamList(p, retColon=false) let pragmas = optPragmas(p) colcom(p, result) result = parseStmt(p) - if params.kind != nkEmpty: + if params.kind != nkEmpty or pragmas.kind != nkEmpty: + if params.kind == nkEmpty: + params = newNodeP(nkFormalParams, p) + params.add(p.emptyNode) # return type result = newProcNode(nkDo, info, body = result, params = params, name = p.emptyNode, pattern = p.emptyNode, genericParams = p.emptyNode, pragmas = pragmas, exceptions = p.emptyNode) @@ -1407,7 +1410,10 @@ proc postExprBlocks(p: var Parser, x: PNode): PNode = if stmtList[0].kind == nkStmtList: stmtList = stmtList[0] stmtList.flags.incl nfBlockArg - if openingParams.kind != nkEmpty: + if openingParams.kind != nkEmpty or openingPragmas.kind != nkEmpty: + if openingParams.kind == nkEmpty: + openingParams = newNodeP(nkFormalParams, p) + openingParams.add(p.emptyNode) # return type result.add newProcNode(nkDo, stmtList.info, body = stmtList, params = openingParams, name = p.emptyNode, pattern = p.emptyNode, @@ -1910,7 +1916,7 @@ proc parseEnum(p: var Parser): PNode = var symPragma = a var pragma: PNode - if p.tok.tokType == tkCurlyDotLe: + if (p.tok.indent < 0 or p.tok.indent >= p.currInd) and p.tok.tokType == tkCurlyDotLe: pragma = optPragmas(p) symPragma = newNodeP(nkPragmaExpr, p) symPragma.add(a) diff --git a/compiler/ast/types.nim b/compiler/ast/types.nim index ef6a6b94d49..80fa3a7ddc7 100644 --- a/compiler/ast/types.nim +++ b/compiler/ast/types.nim @@ -1381,3 +1381,6 @@ proc isCharArrayPtr*(t: PType; allowPointerToChar: bool): bool = result = allowPointerToChar else: discard + +proc lacksMTypeField*(typ: PType): bool {.inline.} = + (typ.sym != nil and sfPure in typ.sym.flags) or tfFinal in typ.flags diff --git a/compiler/ast/wordrecg.nim b/compiler/ast/wordrecg.nim index 32b3272fdad..c663240a4a2 100644 --- a/compiler/ast/wordrecg.nim +++ b/compiler/ast/wordrecg.nim @@ -40,7 +40,7 @@ type wImmediate = "immediate", wConstructor = "constructor", wDestructor = "destructor", wDelegator = "delegator", wOverride = "override", wImportCpp = "importcpp", wCppNonPod = "cppNonPod", - wImportObjC = "importobjc", wImportCompilerProc = "importcompilerproc", + wImportObjC = "importobjc", wImportCompilerProc = "importCompilerProc", wImportc = "importc", wImportJs = "importjs", wExportc = "exportc", wExportCpp = "exportcpp", wExportNims = "exportnims", wIncompleteStruct = "incompleteStruct", # deprecated diff --git a/compiler/backend/ccgcalls.nim b/compiler/backend/ccgcalls.nim index 0eebc33a840..e56bb16d111 100644 --- a/compiler/backend/ccgcalls.nim +++ b/compiler/backend/ccgcalls.nim @@ -215,7 +215,7 @@ proc openArrayLoc(p: BProc, formalType: PType, n: PNode): Rope = else: var a: TLoc initLocExpr(p, if n.kind == nkHiddenStdConv: n[1] else: n, a) - case skipTypes(a.t, abstractVar).kind + case skipTypes(a.t, abstractVar+{tyStatic}).kind of tyOpenArray, tyVarargs: if reifiedOpenArray(n): if a.t.kind in {tyVar, tyLent}: @@ -377,8 +377,8 @@ proc genParams(p: BProc, ri: PNode, typ: PType): Rope = if not needTmp[i - 1]: needTmp[i - 1] = potentialAlias(n, potentialWrites) getPotentialWrites(ri[i], false, potentialWrites) - if ri[i].kind == nkHiddenAddr: - # Optimization: don't use a temp, if we would only take the adress anyway + if ri[i].kind in {nkHiddenAddr, nkAddr}: + # Optimization: don't use a temp, if we would only take the address anyway needTmp[i - 1] = false for i in 1..