summary refs log tree commit diff stats
Commit message (Collapse)AuthorAgeFilesLines
...
* fixes #23524; global variables cannot be analysed when injecting `move` (#23529)ringabout2024-04-244-23/+41
| | | | | | | | | | | | fixes #23524 ```nim proc isAnalysableFieldAccess*(orig: PNode; owner: PSym): bool = ... result = n.kind == nkSym and n.sym.owner == owner and {sfGlobal, sfThread, sfCursor} * n.sym.flags == {} and (n.sym.kind != skParam or isSinkParam(n.sym)) ``` In `isAnalysableFieldAccess`, globals, cursors are already rejected
* * fix for the debug line info code generation (#23488)Nikolay Nikolov2024-04-222-23/+73
| | | | Previously, in certain cases, the compiler would generate debug info for the correct line number, but for the wrong .nim source file.
* updated compiler DFA docs (#23527)Andreas Rumpf2024-04-221-13/+3
|
* Fix std/base64.decode out of bounds read (#23526)bptato2024-04-222-1/+3
| | | | inputLen may end up as 0 in the loop if the input string only includes trailing characters. e.g. without the patch, decode(" ") would panic.
* fix #23518 - `<expr> is` crashes nimsuggest (#23523)José Paulo2024-04-211-1/+2
| | | | | | This solution should resolve the nimsuggest crash issue. However, perhaps the problem is in the parser? fix #23518
* fixes commit hashes (#23520)ringabout2024-04-191-2/+2
|
* allow having {.noinit.} on a complex type avoid memsets to 0 for its … ↵heterodoxic2024-04-182-1/+4
| | | | | | | | | | | | | | | | | | | | | (#23388) …instantiations (C/C++ backend) AFAIK, #22802 expanded `noinit`'s utility by allowing the pragma to be attached to types (thanks @jmgomez !). I suggest broadening the scope a bit further: try to avoid `nimZeroMem`s on a type level beyond imported C/C++ types[^1], saving us from annotating the type instantiations with `noinit`. If this change is deemed acceptable, I will also adjust the docs, of course. Adding tests for this change seems a bit problematic, as the effect of this type annotation will be to work with uninitialized memory, which *might* match 0 patterns. [^1]: "complex value types" as already defined here: https://github.com/nim-lang/Nim/blob/94c599687796f4ee3872c8aa866827b9ed33f52b/compiler/cgen.nim#L470-L471
* Fix duplicated member declarations in structs for C++ backend (#23512)HexSegfaultCat2024-04-182-1/+28
| | | | | | | | | | | | | | | When forward declaration is used with pragmas `virtual` or `member`, the declaration in struct is added twice. It happens because of missing check for `sfWasForwarded` pragma. Current compiler generates the following C++ code: ```cpp struct tyObject_Foo__fFO9b6HU7kRnKB9aJA1RApKw { N_LIB_PRIVATE N_NOCONV(void, abc)(NI x_p1); N_LIB_PRIVATE N_NOCONV(virtual void, def)(NI y_p1); N_LIB_PRIVATE N_NOCONV(void, abc)(NI x_p1); N_LIB_PRIVATE N_NOCONV(virtual void, def)(NI y_p1); }; ```
* workaround #23435; real fix pending #23279 (#23436)ringabout2024-04-182-0/+14
| | | | | | | workaround #23435 related to https://github.com/nim-lang/Nim/issues/22852 see also #23279
* bundle atlas with sat (#23375)ringabout2024-04-181-1/+4
| | | | pending https://github.com/nim-lang/atlas/pull/119 pending AtlasStableCommit updates
* remove php code from jsgen (#23502)ringabout2024-04-181-14/+0
| | | | follow up https://github.com/nim-lang/Nim/pull/7606 https://github.com/nim-lang/Nim/pull/13466
* remove `|| []` from jsgen because string cannot be nil anymore (#23508)ringabout2024-04-181-3/+3
| | | introduced in https://github.com/nim-lang/Nim/pull/9411
* fixes #23492; fixes JS float range causes compiler crash (#23517)ringabout2024-04-181-1/+1
| | | | | | | | | | | | | | | fixes #23492 ```nim proc foo = var x: range[1.0 .. 5.0] = 2.0 case x of 1.0..2.0: echo 1 else: echo 3 foo() ```
* fixes #4695; closure iterators support for JS backend (#23493)ringabout2024-04-186-53/+64
| | | | | | | | | | | | | | | | | | | | | | | fixes #4695 ref https://github.com/nim-lang/Nim/pull/15818 Since `nkState` is only for the main loop state labels and `nkGotoState` is used only for dispatching the `:state` (since https://github.com/nim-lang/Nim/pull/7770), it's feasible to rewrite the loop body into a single case-based dispatcher, which enables support for JS, VM backend. `nkState` Node is replaced by a label and Node pair and `nkGotoState` is only used for intermediary processing. Backends only need to implement `nkBreakState` and `closureIterSetupExc` to support closure iterators. pending https://github.com/nim-lang/Nim/pull/23484 <del> I also observed some performance boost for C backend in the release mode (not in the danger mode though, I suppose the old implementation is optimized into computed goto in the danger mode) </del> allPathsAsgnResult???
* allow Nix builds by not calling git in isGitRepo for Nimble (#23515)Jakub2024-04-181-10/+3
| | | | | | | | | | | | | | | Because `isGitRepo()` call requires `/bin/sh` it will always fail when building Nim in a Nix build sandbox, and the check doesn't even make sense if Nix already provides Nimble source code. Since for Nimble `allowBundled` is set to `true` this effectlvely does not change behavior for normal builds, but does avoid ugly hacks when building in Nix which lacks `/bin/sh` and fails to call `git`. Reference: * https://github.com/status-im/nimbus-eth2/pull/6180#discussion_r1570237858 Signed-off-by: Jakub Sokołowski <jakub@status.im>
* fixes #23505; fixes injectdestructors errors on transformed addr (deref) ↵ringabout2024-04-182-1/+17
| | | | | refs (#23507) fixes #23505
* remove HEAD arraymancer dependency requirement in package CI (#23509)metagn2024-04-171-3/+3
| | | | | Was introduced to handle a break in #23392, according to https://github.com/nim-lang/Nim/pull/23503#issuecomment-2057266475 should not be needed anymore
* fixes #23494; Wrong type in object construction error message (#23504)ringabout2024-04-162-1/+7
| | | fixes #23494
* fixes #23499; don't skip `addr` when constructing `bracketExpr` (#23503)ringabout2024-04-152-1/+11
| | | | | | | | | | | fixes #23499 In the https://github.com/nim-lang/Nim/commit/8990626ca9715a3687b28331aee4ccf242997aa2 the effect of `skipAddr` changed to skip `nkAddr` and `nkHiddenAddr`. Some old code was not adapted. In the https://github.com/nim-lang/Nim/pull/23477, the magic `addr` function was handled in the semantic analysis phase, which causes it be skipped incorrectly
* strictdefs for `repr` so that it can used for debugging purposes in t… ↵ringabout2024-04-151-2/+2
| | | | | (#23501) …he compiler
* fixes #23487; JS chckNilDisp is wrong (#23490)ringabout2024-04-131-1/+1
| | | | | fixes #23487 uses JSRef
* [JS backend] improve `discard` statement; ridding of the awkward special ↵ringabout2024-04-132-2/+2
| | | | | | | | | | variable `_` (#23498) According to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/Expression_statement, some expression statements need parentheses to make it unambiguous. `_` introduced in the https://github.com/nim-lang/Nim/pull/15789 is unnecessary. We can get rid of it by adding parentheses so that object literals are not ambiguous with block statements.
* fix JSON deep copy description (#23495)Pouriya Jamshidi2024-04-121-1/+1
| | | | | | Hi, This is a tiny change, fixing the error in the documentation of JSON's deep copy proc.
* fixes #4299 #12492 #10849; lambda lifting for JS backend (#23484)ringabout2024-04-1110-71/+118
| | | | | | | | fixes #4299 fixes #12492 fixes #10849 It binds `function` with `env`: `function.bind(:env)` to ease codegen for now
* Better documentation for typedthreads module (#23483)Antoine Delègue2024-04-111-27/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added a second example inside the `typedthreads` file. Also, add a more detailed introduction. When Nim is one's first programming language, a short explanation of what a thread is might not hurt. For reference, the thread documentation of other languages looks like this: - https://en.cppreference.com/w/cpp/thread/thread - https://doc.rust-lang.org/std/thread/ The documentation of a module is the first place one will look when using a standard library feature, so I think it is important to have a few usable examples for the main modules. This is the example added ```nim import locks var l: Lock proc threadFunc(obj: ptr seq[int]) {.thread.} = withLock l: for i in 0..<100: obj[].add(obj[].len * obj[].len) proc threadHandler() = var thr: array[0..4, Thread[ptr seq[int]]] var s = newSeq[int]() for i in 0..high(thr): createThread(thr[i], threadFunc, s.addr) joinThreads(thr) echo s initLock(l) threadHandler() deinitLock(l) ``` Sharing memory between threads is very very common, so I think having an example showcasing this is crucial. --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fixes addr/hiddenAddr in strictdefs (#23477)ringabout2024-04-1030-71/+80
|
* remove unused magics: mIntToStr, mInt64ToStr, mFloatToStr (#23486)ringabout2024-04-096-25/+2
| | | mIntToStr, mInt64ToStr, mFloatToStr,
* stop gensym identifiers hijacking routine decl names in templates (#23392)metagn2024-04-095-5/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fixes #23326 In a routine declaration node in a template, if the routine is marked as `gensym`, the compiler adds it as a new symbol to a preliminary scope of the template. If it's not marked as gensym, then it searches the preliminary scope of the template for the name of the routine, then when it matches a template parameter or a gensym identifier, the compiler replaces the name node with a symbol node of the found symbol. This makes sense for the template parameter since it has to be replaced later, but not really for the gensym identifier, as it doesn't allow us to inject a routine with the same name as an identifier previously declared as gensym (the problem in #23326 is when this is in another `when` branch). However this is the only channel to reuse a gensym symbol in a declaration, so maybe removing it has side effects. For example if we have: ```nim proc foo(x: int) {.gensym.} = discard proc foo(x: float) {.gensym.} = discard ``` it will not behave the same as ```nim proc foo(x: int) {.gensym.} = discard proc foo(x: float) = discard ``` behaved previously, which maybe allowed overloading over the gensym'd symbols. A note to the "undeclared identifier" error message has also been added for a potential error code that implicitly depended on the old behavior might give, namely ``undeclared identifier: 'abc`gensym123'``, which happens when in a template an identifier is first declared gensym in code that doesn't compile, then as a routine which injects by default, then the identifier is used.
* Update encodings.nim, fix `open` with bad arg raising no `EncodingError` ↵lit2024-04-062-1/+5
| | | | | | (#23481) On POSIX, `std/encodings` uses iconv, and `iconv_open` returns `(iconv_t) -1` on failure, not `NULL`
* fixes JS tests (#23479)ringabout2024-04-051-1/+1
|
* fixes #23440; fixes destruction for temporary object subclass (#23452)ringabout2024-04-051-3/+13
| | | fixes #23440
* apply the new mangle algorithm to JS backend for parameters and procs (#23476)ringabout2024-04-055-57/+71
| | | | | | | | | | | | | | the function name extension encoded by paths could be useful for debugging where the function is from Before: ```js function newSeq_33556909(len_33556911) ``` After: ```js function newSeq__system_u2477(len_p0) ```
* remove `internalNew` from system (#23475)ringabout2024-04-042-3/+1
|
* remove BountySource which doesn't exist anymore (#23474)ringabout2024-04-041-4/+0
| | | | | | ref https://github.com/nim-lang/website/issues/391 https://news.ycombinator.com/item?id=38419134
* fixes #16771; lower `swap` for JS backend (#23473)ringabout2024-04-033-16/+24
| | | | | | | | | | | | fixes #16771 follow up https://github.com/nim-lang/Nim/pull/16536 Ideally it should be handled in the IR part in the future I have also checked the double evaluation of `swap` in the JS runtime https://github.com/nim-lang/Nim/issues/16779, that might be solved by a copy flag or something. Well, it should be best solved in the IR so that it doesn't bother backends anymore.
* Update syncio.nim, fixes "open by FileHandle" doesn't work on Windows (#23456)lit2024-04-031-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ## Reprodution if on Windows: ```Nim when defined(windows): var file: File let succ = file.open(<aFileHandle>) ``` then `succ` will be false. If tested, it can be found to fail with errno `22` and message: `Invalid argument` ## Problem After some investigations and tests, I found it's due to the `mode` argument for `fdopen`. Currently `NoInheritFlag`(`'N'` in Windows) is added to `mode` arg passed to `_fdopen`, but if referring to [Windows `_fdopen` doc](https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/fdopen-wfdopen?view=msvc-170), you'll find there is no `'N'` describled. That's `'N'` is not accepted by `_fdopen`. Therefore, the demo above will fail. ## In Addition To begin with, technologically speaking, when opening with a `fileHandle`(or called `fd`), there is no concept of fd-inheritable as `fd` is opened already. In POSIX, `NoInheritFlag` is defined as `e`. It's pointed out in [POSIX `open` man-doc](https://www.man7.org/linux/man-pages/man3/fopen.3.html) that `e` in mode is ignored for fdopen(), which means `e` for `fdopen()` is not wanted, just allowed. Therefore, better to also not pass `e` to `fdopen` --- In all, that's this PR.
* fixes testament targets field (#23472)ringabout2024-04-033-3/+3
|
* bump nimble version (#23467)ringabout2024-04-021-2/+2
|
* dynlib keeps exported functions alive in emscripten (#23469)ringabout2024-04-021-5/+12
| | | | | | | | | | | | | | | | | | | ref https://forum.nim-lang.org/t/11338 ref https://github.com/beef331/wasm3/blob/master/src/wasm3/exporter.nim ref https://github.com/emscripten-core/emscripten/issues/6233 ref https://github.com/emscripten-core/emscripten/blob/3.1.56/system/include/emscripten/em_macros.h#L10 `EMSCRIPTEN_KEEPALIVE` is a macro that is used to prevent unused functions from being deadcode eliminated in emscripten, which is a simple wrapper around `__attribute__((used))`. This PR follows suits and expects dynlib is supposed to keep these functions alive. In the future, `exportwasm` might be introduced. After this PR, a function with `{.dynlib, exportc.}` can be reused from other wasm programs reliably.
* fixes #9550; Concept related crash only when compiling to JS (#23470)ringabout2024-04-022-1/+12
| | | fixes #9550
* adds ccMember CC fixes #23434 (#23457)Juan M Gómez2024-03-296-4/+24
|
* fixes #23422; card regression (#23437)ringabout2024-03-282-1/+39
| | | | | | | | | fixes #23422 ref https://github.com/nim-lang/Nim/issues/20997 https://github.com/nim-lang/Nim/pull/21165 The function `cardSet` is used for large sets that are stored in the form of arrays. It shouldn't be passed as a pointer
* fixes #23429; rework `--verbosity` with warnings/hints (#23441)ringabout2024-03-281-0/+5
| | | fixes #23429
* Fix compile time errors when using tables on 8/16-bits systems. (#23450)Gianmarco2024-03-281-1/+4
| | | Refer to the discussion in #23439.
* Converted the 'invalid kind for firstOrd/lastOrd(XXX)' messages from ↵Nikolay Nikolov2024-03-271-4/+4
| | | | | | | | | | internal errors to fatal errors. (#23443) This fixes a nimsuggest crash when opening: beacon_chain/consensus_object_pools/blockchain_dag.nim from the nimbus-eth2 project and many other .nim files (44 files, to be precise) in the same project. Replaces: https://github.com/nim-lang/Nim/pull/23402
* Change unicode lookup tables to have int32 elements to support platforms ↵Gianmarco2024-03-252-9/+9
| | | | | | | | | | | | | | | where sizeof(int) < 4 (#23433) Fixes an issue that comes up when using strutils.`%` or any other strutils/strformat feature that uses the unicode lookup tables behind the scenes, on systems where ints are than 32-bit wide. Tested with: ```bash ./koch test cat lib ``` Refer to the discussion in #23125.
* fix atomicarc increment (#23427)Jaremy Creechley2024-03-251-1/+1
| | | | | | | | | | | | The fix to the atomicArc looks to use `-1` as the check value from the `SharedPtr` solution. However, it should be `-rcIncrement` since the refcount is bit shifted in ARC/ORC. I discovered this playing around doing atomic updates of refcounts in a user library. Related to https://github.com/nim-lang/Nim/issues/22711 @ringabout I believe you ported the sharedptr fix?
* [Cpp] Fixes an issue when mixing hooks and calls (#23428)Juan M Gómez2024-03-213-2/+19
|
* fix: use `ErrorColor` for hints marked as errors (#23430)Igor Sirotin2024-03-211-1/+2
| | | | | | | | | | | | # Description When using `--hintAsError`, we want some red color to appear in the logs. Same is already done for `warningAsError`. # Cherry-picking to Nim 1.6 Would be nice to cherry-pick this and the `warningAsError` log highlight to 1.6 branch, as it's used in status-desktop.
* Adds support for custom ASTs in the Nim parser (#23417)Andreas Rumpf2024-03-186-245/+449
|