summary refs log tree commit diff stats
Commit message (Collapse)AuthorAgeFilesLines
* fixes #22389; fixes #19840; don't fold paths containing `addr` (#23807)ringabout2024-07-093-5/+21
| | | | fixes #22389; fixes #19840
* conditional compilation of gcd(SomeInteger,SomeInteger) in std/math (#23773)quimt2024-07-091-34/+37
| | | | | | | | | | | The most specific version of `gcd(int,int)` in `std/math` uses bitwise comparisons from C compilers, which can't be borrowed on the js platform in the web browser. Conditional compilation here should fix the issue for this and downstream libraries such as `std/rationals` when compiling to browser js as the backend. --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* remove nir; succeeded by nif (#23809)ringabout2024-07-0922-6984/+11
| | | ref https://github.com/nim-lang/nif
* Bumps nimble so the next Nim release includes the latest changes (#23808)Juan M Gómez2024-07-091-1/+1
|
* Add support for nvcc & hipcc (cuda/rocm) (#23805)Andrew Brower2024-07-083-2/+42
| | | | | | | | | | | | | | I've been working on making some basic cuda examples work, both with cuda (nvcc) and with AMD HIP (hipcc) https://github.com/monofuel/hippo - hipcc is just a drop-in replacement for clang and works out of the box with clang settings in Nim. hipcc is capable of compiling for AMD ROCm or to CUDA, depending on how HIP_PLATFORM is set. - nvcc is a little quirky. we can use `-x cu` to tell it to handle nim's `.cpp` files as if they were `.cu` files. nvcc expects all backend compiler flags to be wrapped with a special `-Xcompiler=""` flag when compiling and also when linking. I manually tested on a linux desktop with amd and a laptop with nvidia.
* Adjust the correct chunk's free space in allocator (#23795)SirOlaf2024-07-081-2/+2
| | | Fixes #23788
* Replacement PR for https://github.com/nim-lang/Nim/pull/23779 that (#23793)c-blake2024-07-0711-56/+75
| | | | | | | makes new hash the default, with an opt-out (& js-no-big-int) define. Also update changelog (& fix one typo). Only really expect the chronos hash-order sensitive test to fail until they merge that PR and tag a new release.
* [backport] fixes #23796; remove extra indirection for args in importc'ed ↵Alexander Kernozhitsky2024-07-062-1/+27
| | | | | functions in cpp (#23800) fixes #23796
* Update documentation for parseEnum in strutils.nim (#23804)Leon Lysak2024-07-061-2/+2
| | | | | | | added small note regarding style insensitivity for parsing enums. the casing of the first letter is still taken into account for this function. was confused a little at first because when I read "style insensitive manner" I thought it meant casing as well and ran into a couple of `ValueError`'s because of it.
* fixes #23790; roll back instCounter properly in case of exceptions (#23802)Alexander Kernozhitsky2024-07-063-3/+17
| | | fixes #23790
* Optimize closure iterator locals (#23787)Yuriy Glukhov2024-07-037-124/+174
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This pr redefines the relation between lambda lifting and closureiter transformation. Key takeaways: - Lambdalifting now has less distinction between closureiters and regular closures. Namely instead of lifting _all_ closureiter variables, it lifts only those variables it would also lift for simple closure, i.e. those not owned by the closure. - It is now closureiter transformation's responsibility to lift all the locals that need lifting and are not lifted by lambdalifting. So now we lift only those locals that appear in more than one state. The rest remains on stack, yay! - Closureiter transformation always relies on the closure env param created by lambdalifting. Special care taken to make lambdalifting create it even in cases when it's "too early" to lift. - Environments created by lambdalifting will contain `:state` only for closureiters, whereas previously any closure env contained it. IMO this is a more reasonable approach as it simplifies not only lambdalifting, but transf too (e.g. freshVarsForClosureIters is now gone for good). I tried to organize the changes logically by commits, so it might be easier to review this on per commit basis. Some ugliness: - Adding lifting to closureiters transformation I had to repeat this matching of `return result = value` node. I tried to understand why it is needed, but that was just another rabbit hole, so I left it for another time. @Araq your input is welcome. - In the last commit I've reused currently undocumented `liftLocals` pragma for symbols so that closureiter transformation will forcefully lift those even if they don't require lifting otherwise. This is needed for [yasync](https://github.com/yglukhov/yasync) or else it will be very sad. Overall I'm quite happy with the results, I'm seeing some noticeable code size reductions in my projects. Heavy closureiter/async users, please give it a go.
* fixes #23784; don't allow fold paths containing `nkAddr` (#23792)ringabout2024-07-032-1/+158
| | | | | | | fixes #23784 notes that before https://github.com/nim-lang/Nim/pull/23477, it didn't fold paths containing `addr`/`unsafeAddr` because it retained the form of the magic function: `mAddr`.
* This test for issue 9739 never needed to depend upon hash order (#23791)c-blake2024-07-031-2/+1
| | | | | (for `string` or any other key type). Independence is nice to ever change orders. So, change it to just `len` & a `doAssert` like the other test in the same file.
* fixes #23775; injectdestructors now handles discardable statements (#23780)ringabout2024-07-023-2/+27
| | | fixes #23775
* Fixed issues when using `std/parseopt` in miscripts with cmdline = "" (#23785)Gianmarco2024-07-021-3/+15
| | | | | | | Using initOptParser with an empty cmdline (so that it gets the cmdline from the command line) in nimscripts does not yield the expected results. Fixes #23774.
* Fix doc: '\c' '\L' in lexbase.nim (#23781)lit2024-07-011-4/+4
| | | - In lexbase.nim, `\c` `\L` were rendered as `c` `L`.
* refine: strmisc.expandTabs better code structure (#23783)lit2024-07-011-9/+6
| | | | | | | | | After this pr, for a string with just 20 length and 6 `'\t'`, the time reduces by about 1.5%[^t]. Also, the code is clearer than the previous at some places. [^t]: Generally speaking, this rate increases with length. I may test for longer string later.
* fixes #23755; array static inference during overload resolution (#23760)Ryan McConnell2024-07-013-11/+71
| | | | | | | #23755 --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Revert "Document move limitations" (#23778)Andreas Rumpf2024-07-011-1/+0
| | | | | Reverts nim-lang/Nim#23763 Too vague and fear inducing.
* fixes #5091; Ensure we don't wait on an exited process on Linux (#23743)Mark Leyva2024-07-012-0/+20
| | | | | Fixes #5091. Ensure we don't wait on an exited process on Linux
* [backport] fixes #23748; do not skip materializing temporaries for proc ↵Alexander Kernozhitsky2024-06-303-4/+48
| | | | | arguments (#23769) fixes #23748
* Comment out flaky test in tests/stdlib/thttpclient (#23772)Alexander Kernozhitsky2024-06-291-6/+6
| | | | | | | | | ``` $ curl -v http://example.com/404 |& grep 'HTTP/1.1' > GET /404 HTTP/1.1 < HTTP/1.1 500 Internal Server Error ``` So, the test with http://example.com/404 should be disabled, I think.
* Document move limitations (#23763)Juan Carlos2024-06-291-0/+1
| | | | - See https://github.com/nim-lang/Nim/issues/23759#issuecomment-2192123783
* Bumps nimble to entryPoints commit (#23766)Juan M Gómez2024-06-291-1/+1
|
* fixes #23759; rework move for refc (#23764)ringabout2024-06-293-3/+18
| | | fixes #23759
* fixes #9940; genericAssign does not take care of the importC variables in ↵ringabout2024-06-263-3/+34
| | | | | refc [backport] (#23761) fixes #9940
* fixes #23725; Size computations work better when they are correct (#23758)Andreas Rumpf2024-06-261-6/+10
| | | [backport]
* adapt semOpAux to opt-in symchoices (#23750)metagn2024-06-252-1/+38
| | | | | | | | fixes #23749, refs #22716 `semIndirectOp` is used here because of the callback expressions, in this case `db.getProc(...)`, and `semIndirectOp` calls `semOpAux` to type its arguments before overloading starts. Hence it can opt in to symchoices since overloading will resolve them.
* Check for nil in cstringArrayToSeq (#23747)Yuriy Glukhov2024-06-241-0/+2
| | | | | | | | This fixes crashes in some specific network configurations (as `cstringArrayToSeq` is used extensively in `nativesockets`). --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* remove bench action to save resources, which is barely useful (#23753)ringabout2024-06-241-115/+0
|
* Run tests with `nimPreviewHashFarm` on the 3 main back ends. (#23739)c-blake2024-06-221-1/+1
| | | | Assuming CI tests pass (they do for me locally), this should be merged to keep them passing.
* fixes #23742; setLen(0) no longer allocates memory for uninitialized ↵ringabout2024-06-211-2/+8
| | | | | | | | | | strs/seqs for refc (#23745) fixes #23742 Before my PR, `setLen(0)` doesn't free buffer if `s != nil`, but it allocated unnecessary memory for `strs`. This PR rectifies this behavior. `setLen(0)` no longer allocates memory for uninitialized strs/seqs
* [backport] fixes #23711; C code contains backtick`gensym (#23716)ringabout2024-06-196-7/+40
| | | fixes #23711
* Add Farm Hash conditioned upon `nimPreviewHashFarm` as 64-bit `Hash` (#23735)c-blake2024-06-193-25/+199
| | | | | | | | | | | | | | | | | | | | | | | | | Unlike present Nim this actually fills `Hash` for `string` & related. For the curious, note that `hashData` remains the aboriginal Nim string hasher & `import hashes {.all.}` allows simultaneous test/time of {orig, murmur, farm} on your favorite CPU & back end compiler. Update tests also conditioned upon `nimPreviewHashFarm` so they should pass either with or without that `define` on. In `--jsbigint=on` mode, only the lower 32-bits of `Hash` match nimvm & run-time values because `type Hash = int` and on JS int=int32, not int64 as for 64-bit Nim platforms. Due to the matching, `const` Table should match run-time `Table` on all platforms. To operate in `--jsbigint=off` mode is feasible but needs much "double precision mul/xor/ror/shr-arithmetic"-style work. That is distracting & also of questionable value since JS added BigInt in 2018, ringabout added Nim support for it in 2021 & `nimPreviewHashFarm` is unlikely to swap from an opt-in to an opt-out default before 2025..2026 which will have given a backward looking time window of 7..8 years for deployment platforms - reasonably generous. Add a changelog entry for 2.2.
* adds a define nimHasJsNoLambdaLifting so we can use it in the config for ↵ringabout2024-06-191-0/+1
| | | | compatibility (#23736)
* IC: use tables instead of huge seqs because the compiler can create l… ↵Andreas Rumpf2024-06-185-49/+67
| | | | | (#23737) …ots of dummy syms and types
* fixes #23732, os.sleep(-1) now returns immediately (#23734)lit2024-06-181-0/+3
| | | fixes #23732
* disable dnsclient because it is fragile (#23728)ringabout2024-06-181-1/+1
| | | | | | | | | | | | | | | ``` Unhandled exception: /home/runner/work/Nim/Nim/pkgstemp/dnsclient/tests/test1.nim(28, 3) `rr.strings == @["dnsclient.nim"]` [AssertionDefect] [FAILED] query TXT [OK] query MX [OK] query CNAME [OK] query SRV Error: execution of an external program failed: '/home/runner/work/Nim/Nim/pkgstemp/dnsclient/tests/test1' Tip: 2 messages have been suppressed, use --verbose to show them. tools.nim(36) doCmd Error: Execution failed with exit code 1 ... Command: /home/runner/work/Nim/Nim/bin/nim c --noNimblePath -d:NimblePkgVersion=0.3.4 --hints:off -r --path:. /home/runner/work/Nim/Nim/pkgstemp/dnsclient/tests/test1 ```
* ignore uninstantiated static on match to base type [backport:2.0] (#23731)metagn2024-06-182-2/+10
| | | | | | | | | | | | | | | | | | | | | fixes #23730 Since #23188 the compiler errors when matching a type variable to an uninstantiated static value. However sometimes an uninstantiated static value is given even when only a type match is being performed to the base type of the static type, in the given issue this case is: ```nim proc foo[T: SomeInteger](x: T): int = int(x) proc bar(x: static int): array[foo(x), int] = discard discard bar(123) ``` To deal with this issue we only error when matching against a type variable constrained to `static`. Not sure if the `q.typ.kind == tyGenericParam and q.typ.genericConstraint == tyStatic` check is necessary, the code above for deciding whether the variable becomes `skConst` doesn't use it.
* Fix NIM_STATIC_ASSERT_AUX being redefined on different lines (#23729)fakuivan2024-06-181-4/+8
| | | | | | | | | fixes #17247 This generates a new NIM_STATIC_ASSERT_AUX variable for each line that NIM_STATIC_ASSERT is called from. While this can solve all existing issues in the current code base, this method is not effective for multiple asserts on a single line.
* implement `legacy:jsNoLambdaLifting` for compatibility (#23727)ringabout2024-06-176-19/+76
|
* fixes #20048; fixes #15746; don't sink object fields if it's of openarray ↵ringabout2024-06-153-1/+24
| | | | | | type (#23608) fixes #20048 fixes #15746
* Fix example code in Nim manual that cannot be compiled without error (#23722)Tomohiro2024-06-151-1/+1
|
* ref #20653; fixes chronos empty case branches (#23706)ringabout2024-06-141-7/+11
| | | | | | | | | | | | | | | ref #20653 ```nim Error* = object case kind*: ErrorType of ErrorA: discard of ErrorB: discard ``` For an object variants without fields, it shouldn't generate empty brackets for default values since there are no fields at all in case branches.
* fixes a long standing bug with varargs type inference [backport] (#23720)Andreas Rumpf2024-06-141-1/+1
|
* Fix non-exported `memfiles.setFileSize` to be able to shrink files on posix ↵c-blake2024-06-141-36/+30
| | | | | | | | | | | | | | via `memfiles.resize` (#23717) Fix non-exported `setFileSize` to take optional `oldSize` to (on posix) shrink differently than it grows (`ftruncate` not `posix_fallocate`) since it makes sense to assume the higher address space has already been allocated there and include the old file size in the `proc resize` call. Also, do not even try `setFileSize` in the first place unless the `open` itself works by moving the call into the `if newFileSize != -1` branch. Just cosmetics, also improve some old 2011 comments, note a logic diff for callers using both `mappedSize` & `newFileSize` from windows branch in case someone wants to fix that & simplify code formatting a little.
* nrvo for embedded importc'ed types (#23708)ringabout2024-06-121-3/+6
|
* fixes #22927; no test case extractable [backport] (#23707)Andreas Rumpf2024-06-121-11/+23
|
* fixes #23513, parseutils.nim: parseInt's doc example. (#23561)lit2024-06-121-8/+12
| | | | | | | | | | fixes #23513 Also, the old `runnableExample` is just a copy of `proc parseInt(openArray[char], var int, int)` variant (in Line 1000). --------- Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* [backport] fixes #23690; SIGSEGV with object variants and RTTI (#23703)ringabout2024-06-112-3/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fixes #23690 ```nim dest.`:state` = src.`:state` var :tmp_553651276 = dest.e1.a `=wasMoved`(dest.e1.a) dest.e1.a.kind = src.e1.a.kind case dest.e1.a.kind of 0: dest.e1.a.a = src.e1.a.a of 1: `=copy`(dest.e1.a.c, src.e1.a.c) case :tmp_553651276.kind of 0: of 1: `=destroy`(:tmp_553651276.c) ``` `dest.e1.a.kind = src.e1.a.kind` changes the discrimant but it fails to clear the memory of `dest.e1.a`. Before using hooks for copying, we need to clear the dest, e.g. `=wasMoved(dest.e1.a.c)`. ```nim dest.`:state` = src.`:state` var :tmp_553651276 = dest.e1.a `=wasMoved`(dest.e1.a) dest.e1.a.kind = src.e1.a.kind case dest.e1.a.kind of 0: `=wasMoved`(dest.e1.a.a) dest.e1.a.a = src.e1.a.a `=wasMoved`(dest.e1.a.b) of 1: `=wasMoved`(dest.e1.a.c) `=copy`(dest.e1.a.c, src.e1.a.c) case :tmp_553651276.kind of 0: of 1: `=destroy`(:tmp_553651276.c) ```