summary refs log tree commit diff stats
Commit message (Collapse)AuthorAgeFilesLines
...
* fixes nimsuggest sug doesnt return anything on first pass #23283 (#23288)Juan M Gómez2024-02-151-8/+6
| | | fixes #23283
* fixes refc with non-var destructor; cancel warnings (#23156)ringabout2024-02-134-7/+23
| | | fixes https://forum.nim-lang.org/t/10807
* fixes #18104; tranform one liner var decl before templates expansion (#23294)ringabout2024-02-132-0/+25
| | | fixes #18104
* fixes a nimsuggest crash on init (#23300)Juan M Gómez2024-02-111-1/+1
|
* Remove mask field from Deque (#23299)Tomohiro2024-02-111-5/+6
| | | | | | | | | It seems Deque doesn't need `mask` field because `data.len - 1` equals to `mask`. Deque without `mask` field passes test `tests/stdlib/tdeques.nim`. --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* nimsuggest --ic:on compiles (#23298)Juan M Gómez2024-02-092-0/+21
|
* MangleProcs following the Itanium spec so they are demangled in the debugger ↵Juan M Gómez2024-02-094-6/+276
| | | | | | | | | call stack (#23260) ![image](https://github.com/nim-lang/Nim/assets/1496571/0d796c5b-0bbf-4bb4-8c95-c3e3cce22f15) --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Add items and contains to heapqueue (#23296)Antonis Geralis2024-02-091-0/+15
| | | | The implementation of these functions are trivial yet they were missing from the module.
* fixes #23275; Add `==` for Deque (#23276)Tomohiro2024-02-082-1/+77
|
* fixes regression #23280; Operations on inline toOpenArray len return a wrong ↵ringabout2024-02-062-3/+13
| | | | | result (#23285) fixes #23280
* closes #14710; adds a test case (#23277)ringabout2024-02-051-0/+10
| | | closes #14710
* [fix] nimsuggest `con` sometimes doesnt return anything on first pass fixes ↵Juan M Gómez2024-02-051-2/+3
| | | | | #23281 (#23282) fixes #23281
* follow up #22380; fixes incorrect usages of `newWideCString` (#23278)ringabout2024-02-054-5/+6
| | | follow up #22380
* Docs-improve: os.getCurrentCompilerExe replace with clearer short-desc (#23270)litlighilit2024-02-021-1/+1
| | | | | | | | | | | | | | | | | The doc for `getCurrentCompilerExe` was originally added at [this commit](https://github.com/nim-lang/Nim/commit/c4e3c4ca2d0a1f44ed1e3dd9db564b66031f0843), saying "`getAppFilename` at CT", and modified as "This is `getAppFilename()`_ at compile time..." since [this](https://github.com/nim-lang/Nim/commit/0c2c2dca2a8a3bcdb9729021d1f4734b8db9efbd#diff-8ed10106605d9e0e3f28a927432acd8312e96791c96dbb126a52a7010cf4b44a) Which means "at compile time, get result innerly from Nim compiler via `getAppFilename`", not "get from nim programs". Thus, the doc was confusing, only mentioning `compile time` and `getAppFilename` --------- Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* fixes regression #22909; don't optimize result init if statements can raise ↵ringabout2024-02-012-10/+31
| | | | | | | | | | | | | | | | which corrupts the compiler (#23271) fixes #22909 required by https://github.com/nim-lang/Nim/pull/23267 ```nim proc foo: string = assert false result = "" ``` In the function `foo`, `assert false` raises an exception, which can cause `result` to be uninitialized if the default result initialization is optimized out
* compute checksum of nim files early in the pipelines (#23268)ringabout2024-01-315-8/+25
| | | | related https://github.com/nim-lang/Nim/issues/21717 configs will be resolved later
* minor fixes for std prefix in the compiler (#23269)ringabout2024-01-301-2/+2
|
* Additional speed ups of complex.pow (#23264)Angel Ezquerra2024-01-291-8/+25
| | | | | | | | | | | | | | | | | | | | | This PR speeds up complex.pow when both base and exponent are real; when only the exponent is real; and when the base is Euler's number. These are some pretty common cases which appear in many formulas. The speed ups are pretty significant. According to my measurements (using the timeit library) when both base and exponent are real the speedup is ~2x; when only the exponent is real it is ~1.5x and when the base is Euler's number it is ~2x. There is no measurable difference when using other exponents which makes sense since I refactored the code a little to reduce the total number of branches that are needed to get to the final "fallback" branch, and those branches have less comparisons. Anecdotally the fallback case feels slightly faster, but the improvement is so small that I cannot claim an improvement. If it is there it is perhaps in the order of 3 or 4%. --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Update cmdline.nim, fix broken (dragged) doc-reference for getAppFile… ↵litlighilit2024-01-281-4/+4
| | | | | | | | (#23262) In doc, there are 4 references for `getAppFilename` `getAppFilename` is still in `os`, but the references refer it as if it's in the current module `cmdline`
* clean up goto exceptions; remove the setjmp.h dep (#23259)ringabout2024-01-273-35/+53
|
* fixes #19977; rework inlining of 'var openarray' iterators for C++ (#23258)ringabout2024-01-262-2/+3
| | | fixes #19977
* fixes #23247; don't destroy openarray since it doesn't own the data (#23254)ringabout2024-01-262-2/+59
| | | | | | | | | | | | | | | | | | | | | | | fixes #23247 closes #23251 (which accounts for why the openarray type is lifted because ops are lifted for openarray conversions) related: https://github.com/nim-lang/Nim/pull/18713 It seems to me that openarray doesn't own the data, so it cannot destroy itself. The same case should be applied to https://github.com/nim-lang/Nim/issues/19435. It shouldn't be destroyed even openarray can have a destructor. A cleanup will be followed for https://github.com/nim-lang/Nim/pull/19723 if it makes sense. According to https://github.com/nim-lang/Nim/pull/12073, it lifts destructor for openarray when openarray is sunk into the function, when means `sink openarray` owns the data and needs to destroy it. In other cases, destructor shouldn't be lifted for `openarray` in the first place and it shouldn't destroy the data if it doesn't own it. --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Fixes #23085: update grammars for 'concept' (#23256)Silly Carbon2024-01-262-3/+4
| | | Fixes #23085
* fixes #22597; avoid side effects for call returning openArray types (#23257)ringabout2024-01-264-6/+37
| | | | | | | | | | | | | | fixes #22597 ```nim proc autoToOpenArray*[T](s: Slice[T]): openArray[T] = echo "here twice" result = toOpenArray(s.p, s.first, s.last) ``` For functions returning openarray types, `fixupCall` creates a temporary variable to store the return value: `let tmp = autoToOpenArray()`. But `genOpenArrayConv` cannot handle openarray assignements with side effects. It should have stored the right part of the assignment first instead of calling the right part twice.
* fixes broken doc links (#23255)ringabout2024-01-252-2/+2
| | | | | https://nim-lang.github.io/Nim/testament.html#writing-unit-tests https://nim-lang.github.io/Nim/testament.html#writing-unit-tests-output-message-variable-interpolation
* Fix system.currentSourcePath() documentation [backport 2.0] (#23243)rockcavera2024-01-231-4/+5
| | | | | The documentation links for `parentDir()` and `getCurrentDir()` are broken as they are no longer part of `std/os`. Link changed to `std/private/ospaths2`.
* Show error when trying to run in folder that doesn't exist instead of ↵Jake Leahy2024-01-232-1/+8
| | | | | | | assertion (#23242) Closes #23240 Fixes regression caused by #23017
* account for nil return type in tyProc sumGeneric (#23250)metagn2024-01-232-1/+19
| | | fixes #23249
* closes #15176; adds a test case (#23248)ringabout2024-01-223-68/+90
| | | closes #15176
* remove unreachable code (#23244)ringabout2024-01-221-1/+0
|
* fixes a broken link in `std/algorithm` (#23246)ringabout2024-01-221-1/+1
| | | https://nim-lang.github.io/Nim/manual.html#procedures-do-notation
* Speed up complex.pow when the exponent is 2.0 or 0.5 (#23237)Angel Ezquerra2024-01-201-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR speeds up the calculation of the power of a complex number when the exponent is 2.0 or 0.5 (i.e the square and the square root of a complex number). These are probably two of (if not) the most common exponents. The speed up that is achieved according to my measurements (using the timeit library) when the exponent is set to 2.0 or 0.5 is > x7, while there is no measurable difference when using other exponents. For the record, this is the function I used to mesure the performance: ```nim import std/complex import timeit proc calculcatePows(v: seq[Complex], factor: Complex): seq[Complex] {.noinit, discardable.} = result = newSeq[Complex](v.len) for n in 0 ..< v.len: result[n] = pow(v[n], factor) let v: seq[Complex64] = collect: for n in 0 ..< 1000: complex(float(n)) echo timeGo(calculcatePows(v, complex(1.5))) echo timeGo(calculcatePows(v, complex(0.5))) echo timeGo(calculcatePows(v, complex(2.0))) ``` Which with the original code got: > [177μs 857.03ns] ± [1μs 234.85ns] per loop (mean ± std. dev. of 7 runs, 1000 loops each) > [128μs 217.92ns] ± [1μs 630.93ns] per loop (mean ± std. dev. of 7 runs, 1000 loops each) > [136μs 220.16ns] ± [3μs 475.56ns] per loop (mean ± std. dev. of 7 runs, 1000 loops each) While with the improved code got: > [176μs 884.30ns] ± [1μs 307.30ns] per loop (mean ± std. dev. of 7 runs, 1000 loops each) > [23μs 160.79ns] ± [340.18ns] per loop (mean ± std. dev. of 7 runs, 10000 loops each) > [19μs 93.29ns] ± [1μs 128.92ns] per loop (mean ± std. dev. of 7 runs, 10000 loops each) That is, the new optimized path is 5.6 (23 vs 128 us per loop) to 7.16 times faster (19 vs 136 us per loop), while the non-optimized path takes the same time as the original code.
* fixes #23233; Regression when using generic type with Table/OrderedTable ↵ringabout2024-01-192-2/+22
| | | | | (#23235) fixes #23233
* Make `data-theme` default to "auto" in HTML (#23222)Jake Leahy2024-01-1913-13/+13
| | | | | | | | | Makes docs default to using browser settings instead of light mode This should fix #16515 since it doesn't require the browser to run the JS to set the default Also means that dark mode can be used without JS if the browser is configured to default to dark mode
* Fixing overload resolution documentation (#23171)Ryan McConnell2024-01-191-22/+64
| | | As requested. Let me know where adjustments are wanted.
* fix mime types data (#23226)Bung2024-01-192-1725/+854
| | | | | | generated via https://github.com/bung87/mimetypes_gen source data: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/conf/mime.types?view=co
* Make std/math classify work without `--passc:-fast-math`. (#23211)Angel Ezquerra2024-01-181-3/+2
| | | | By using the existing isNaN function we can make std/math's classify function work even if `--passc:-fast-math` is used.
* fixes #22218; avoids cursor when copy is disabled (#23209)ringabout2024-01-182-1/+28
| | | fixes #22218
* fixes #12334; keeps `nkHiddenStdConv` for cstring conversions (#23216)ringabout2024-01-182-0/+12
| | | | | | fixes #12334 `nkHiddenStdConv` shouldn't be removed if the sources aren't literals, viz. constant symbols.
* Nim Compiler User Guide: Add explanations about lto and strip (#23227)Tomohiro2024-01-181-3/+10
|
* fix wrong subtype relation in tuples & infer some conversions (#23228)metagn2024-01-184-3/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | fixes #18125 Previously a tuple type like `(T, int)` would match an expected tuple type `(U, int)` if `T` is a subtype of `U`. This is wrong since the codegen does not handle type conversions of individual tuple elements in a type conversion of an entire tuple. For this reason the compiler already does not accept `(float, int)` for a matched type `(int, int)`, however the code that checked for which relations are unacceptable checked for `< isSubtype` rather than `<= isSubtype`, so subtypes were not included in the unacceptable relations. Update: Now only considered unacceptable when inheritance is used, as in [`paramTypesMatch`](https://github.com/nim-lang/Nim/blob/3379d26629f30e6be8d303a36e220d1039eb4551/compiler/sigmatch.nim#L2252-L2254). Ideally subtype relations that don't need conversions, like `nil`, `seq[empty]`, `range[0..5]` etc would be their own relation `isConcreteSubtype` (which would also allow us to differentiate with `openArray[T]`), but this is too big of a refactor for now. To compensate for this making things like `let x: (Parent, int) = (Child(), 0)` not compile (they would crash codegen before anyway but should still work in principle), type inference for tuple constructors is updated such that they call `fitNode` on the fields and their expected types, so a type conversion is generated for the individual subtype element.
* error on large integer types as array index range (#23229)metagn2024-01-182-3/+24
| | | | | | | | | | fixes #17163, refs #23204 Types that aren't `tyRange` and are bigger than 16 bits, so `int32`, `uint64`, `int` etc, are disallowed as array index range types. `tyRange` is excluded because the max array size is backend independent (except for the specific size of `high(uint64)` which crashes the compiler) and so there should still be an escape hatch for people who want bigger arrays.
* workaround arrayWith issues (#23230)ringabout2024-01-181-1/+2
| | | I'm working on it, but it's quite tricky. I will fix it soon
* fix(#23231): add nimdoc.cls to installer script (#23232)daylin2024-01-181-1/+1
| | | | | | Change to `compiler/installer.ini` to add `nimdoc.cls` to files copied by installer script. Closes #23231
* give typedesc param nodes type T not typedesc[T] [backport:2.0] (#23115)metagn2024-01-183-3/+15
| | | | | | | fixes https://github.com/nim-lang/Nim/issues/23112, fixes a mistake in https://github.com/nim-lang/Nim/pull/22581 This makes `getType(t)` where `t` is a typedesc param with value `T` equal to `getType(T)`.
* Fix reset code gen for range types (#22462, #23214) (#23215)Giuliano Mega2024-01-182-2/+22
| | | | | | This PR modifies `specializeResetT` so that it generates the proper reset code for range types. I've tested it in the examples for issues #23214 and #22462 as well as our codebase, and it seems to fix the issues I had been experiencing.
* Add `^` operator support for Rational numbers (#23219)Angel Ezquerra2024-01-181-0/+20
| | | | Since pow() cannot be supported for rationals, we support negative integer exponents instead.
* fixes #23223; prevents `insert` self-assignment (#23225)ringabout2024-01-182-0/+9
| | | fixes #23223
* don't use previous bindings of `auto` for routine return types (#23207)metagn2024-01-1710-53/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fixes #23200, fixes #18866 #21065 made it so `auto` proc return types remained as `tyAnything` and not turned to `tyUntyped`. This had the side effect that anything previously bound to `tyAnything` in the proc type match was then bound to the proc return type, which is wrong since we don't know the proc return type even if we know the expected parameter types (`tyUntyped` also [does not care about its previous bindings in `typeRel`](https://github.com/nim-lang/Nim/blob/ab4278d2179639f19967431a7aa1be858046f7a7/compiler/sigmatch.nim#L1059-L1061) maybe for this reason). Now we mark `tyAnything` return types for routines as `tfRetType` [as done for other meta return types](https://github.com/nim-lang/Nim/blob/18b5fb256d4647efa6a64df451d37129d36e96f3/compiler/semtypes.nim#L1451), and ignore bindings to `tyAnything` + `tfRetType` types in `semtypinst`. On top of this, we reset the type relation in `paramTypesMatch` only after creating the instantiation (instead of trusting `isInferred`/`isInferredConvertible` before creating the instantiation), using the same mechanism that `isBothMetaConvertible` uses. This fixes the issues as well as making the disabled t15386_2 test introduced in #21065 work. As seen in the changes for the other tests, the error messages give an obscure `proc (a: GenericParam): auto` now, but it does give the correct error that the overload doesn't match instead of matching the overload pre-emptively and expecting a specific return type. tsugar had to be changed due to #16906, which is the problem where `void` is not inferred in the case where `result` was never touched.
* + show the inferred exception list (as part of the type) for functions that ↵Nikolay Nikolov2024-01-1514-43/+59
| | | | don't have an explicit `.raises` pragma (#23193)