summary refs log tree commit diff stats
Commit message (Collapse)AuthorAgeFilesLines
...
* allow generic compileTime proc folding (#22022)metagn2024-08-185-2/+40
| | | | | | | | | | | | | | fixes #10753, fixes #22021, refs #19365 (was fixed by #22029, but more faithful test added) For whatever reason `compileTime` proc calls did not fold if the proc was generic ([since this folding was introduced](https://github.com/nim-lang/Nim/commit/c25ffbf2622a197c15a4a3bd790b1bc788db2c7f#diff-539da3a63df08fa987f1b0c67d26cdc690753843d110b6bf0805a685eeaffd40)). I'm guessing the intention was for *unresolved* generic procs to not fold, which is now the logic. Non-magic `compileTime` procs also now don't fold at compile time in `typeof` contexts to avoid possible runtime errors (only the important) and prevent double/needless evaluation.
* always lookup pure enum symbols if expected type is enum (#23976)metagn2024-08-173-3/+20
| | | | | | | | | | | | | | | | | | | | fixes #23689 Normally pure enum symbols only "exist" in lookup if nothing else with the same name is in scope. But if an expression is expected to be an enum type, we know that ambiguity can be resolved between different symbols based on their type, so we can include the normally inaccessible pure enum fields in the ambiguity resolution in the case that the expected enum type is actually a pure enum. This handles the use case in the issue of the type inference for enums reverted in #23588. I know pure enums are supposed to be on their way out so this might seem excessive, but the `pure` pragma can't be removed in the code in the issue due to a redefinition error, they have to be separated into different modules. Normal enums can still resolve the ambiguity here though. I always think about making a list of all the remaining use cases for pure enums and I always forget. Will close #23694 if CI passes
* bump checksums (#23975)ringabout2024-08-171-1/+1
| | | | ref https://github.com/nim-lang/checksums/pull/16 ref https://github.com/nim-lang/Nim/pull/23970
* fixes docgen regression: don't add newLine for code if it's the first line ↵ringabout2024-08-174-14/+11
| | | | | | | | | | | | | | | (#23154) Before (devel) ![image](https://github.com/nim-lang/Nim/assets/43030857/cde37109-027a-46c1-a37e-1d6062e6c609) After (this PR and stable) ![image](https://github.com/nim-lang/Nim/assets/43030857/3366877c-7223-4749-a584-fe93f731281f) It now keeps the same behavior as before
* fixes default float ranges (#23957)ringabout2024-08-163-6/+22
|
* fix `is` with `type`/`typedesc` crashing the compiler (#23967)metagn2024-08-162-2/+5
| | | | | | | | | | fixes #22850 The `is` operator checks the type of the left hand side, and if it's generic or if it's a `typedesc` type with no base type, it leaves it to be evaluated later. But `typedesc` types with no base type precisely describe the default typeclass `type`/`typeclass`, so this condition is removed. Maybe at some point this represented an unresolved generic type?
* remove nontoplevel type hack + consider symbol disamb in type hash (#23969)metagn2024-08-163-4/+13
| | | | | | | | | | | | | | fixes #22571 Removes the hack added in #13589 which made non-top-level object type symbols `gensym` because they couldn't be mangled into different names for codegen vs. top-level types. Now we consider the new `disamb` field (added in #21667) of the type symbols in the type hash (which is used for the mangled name) to differentiate between the types. In other parts of the compiler, specifically the [proc mangling](https://github.com/nim-lang/Nim/blob/298ada3412c9cf5971abc2b3b891b9bb8612e170/compiler/mangleutils.nim#L59), `itemId.item` is used instead of the `disamb` field, but I didn't use it in case it's the outdated method.
* fixes #23954; uint8 > 8 bit at compile-time (#23955)ringabout2024-08-152-1/+7
| | | fixes #23954
* disable presto (#23958)ringabout2024-08-151-1/+1
|
* better examples for std/inotify (#23415)Archar Gelod2024-08-141-11/+21
| | | | | | | | | | | | | | | | | Previous example wouldn't run unless `std/posix` was imported and it wasn't mentioned anywhere in the docs. Other changes in the example: - replaced magic number with constant `MaxWatches` . - changed seq buffer to array, because length is already constant + pointer is a bit nicer: `addr seq[0]` vs `addr arr` - added example for getting a `cstring` name value from `InotifyEvent` struct with explicit cast. - added a bit more description to `inotify_init1` (copied from `man inotify(7)`) --------- Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* supports `default` for range types using `firstOrd` with ↵ringabout2024-08-132-5/+26
| | | | | `nimPreviewRangeDefault` (#23950) ref https://github.com/nim-lang/Nim/issues/23943
* fixes #23947; .uint8 compile-time error (#23948)ringabout2024-08-132-11/+24
| | | fixes #23947
* fix #23817; Use __builtin_saddl_overflow variants for arm-none-eabi-gcc. ↵Mark Leyva2024-08-121-3/+11
| | | | | | | | | | | | | | | | | | | | (#23835) Provides a fix for #23817. With target `arm-none-eabi`, GCC defines `int32_t` to `long int`. Nim uses `__builtin_sadd_overflow` for 32-bit targets, but this emits warnings on GCC releases 13 and under, while generating an error on GCC 14. More info regarding this [here](https://gcc.gnu.org/gcc-14/porting_to.html#c) and [here](https://gcc.gnu.org/pipermail/gcc-cvs/2023-December/394351.html). The proposed PR attempts to address this issue for these targets by defining the `nimAddInt`, `nimSubInt`, and `nimMulInt` macros to use the appropriate compiler intrinsics for this platform. As for as we know, the LLVM toolchain for bare metal Arm does not define `int32_t` as `long int` and has no need for this patch. Thus, we only define the above macros for GCC targeting `arm-non-eabi`.
* Adds `SEQ_DECL_SIZE 1` back under `clang` and a test (#23942)Juan M Gómez2024-08-123-1/+14
|
* opensym as node kind + fixed experimental switch (#23892)metagn2024-08-1219-47/+166
| | | | | | | | | | | | | | | refs https://github.com/nim-lang/Nim/pull/23873#discussion_r1687995060, fixes #23386, fixes #23385, supersedes #23572 Turns the `nfOpenSym` node flag implemented in #23091 and extended in #23102 and #23873, into a node kind `nkOpenSym` that forms a unary node containing either `nkSym` or `nkOpenSymChoice`. Since this affects macros working on generic proc AST, the node kind is now only generated when the experimental switch `genericsOpenSym` is enabled, and a new node flag `nfDisabledOpenSym` is set to the `nkSym` or `nkOpenSymChoice` when the switch is not enabled so that we can give a warning. Now that the experimental switch has more reasonable semantics, we define `nimHasGenericsOpenSym2`.
* fixes #23913; empty SEQ_DECL_SIZE (#23940)Tomohiro2024-08-121-3/+1
|
* Implemented `compileOption` for `experimental` to test if a feature i… ↵Don-Duong Quach2024-08-123-1/+47
| | | | | | | | (#23933) …s enabled at compile time. #8644 This doesn't handle the case if `{.push experimental.}` is used, but at least we can test if a feature was enabled globally.
* fixes #23936; opcParseFloat accepts the wrong register as the first param ↵ringabout2024-08-122-1/+12
| | | | | | [backport] (#23941) fixes #23936 follow up https://github.com/nim-lang/Nim/pull/20527
* impr: std/cpuinfo: use documented impl ; support JS (#23911)lit2024-08-111-60/+81
| | | | | | | | | | | | | | | | | | | | | | | Currently `cpuinfo.countProcessor` uses hard-coded `HW_AVAILCPU=25` for both MacOS and BSD; However, [There is no HW_AVAILCPU on FreeBSD, NetBSD, and OpenBSD]( https://bugs.webkit.org/show_bug.cgi?id=132542) Also, `HW_AVAILCPU` is undocmented in MacOS, while `sysctlbyname("hw.logicalcpu",...)` is documented and used by many other languages' implementations, like [Haskell](https://gitlab.haskell.org/ghc/ghc/-/blob/master/rts/posix/OSThreads.c?ref_type=heads#L376) --- This PR: - use `importc` value instead of hard-coded values for `HW_*` macros. - use "hw.logicialcpu" over undocumented HW_AVAILCPU. - reduce 2 elements of `mib` array when calling `sysctl` as they're no use.
* fixes jsbigint64 regression; keeps convs to `Number` in danger mode (#23926)ringabout2024-08-112-1/+24
| | | fixes jsbigint64 regression
* fixes #23932; vmopsDanger for os.getCurrentDir errors (#23934)ringabout2024-08-112-4/+8
| | | | fixes #23932 ref https://github.com/jmgomez/NimForUE/issues/36
* don't treat template/macro/module as overloaded for opensym (#23939)metagn2024-08-113-3/+8
| | | | | | | | | | | | | | actually fixes #23865 following up #23873 In the handling of `nkIdent` in `semExpr`, the compiler looks for the closest symbol with the name and [checks the symbol kind](https://github.com/nim-lang/Nim/blob/6126a0bf46f4e29a368b8baefea69a2bcae54e93/compiler/semexprs.nim#L3171) to also consider the overloads if the symbol kind is overloadable. But it treats the normally overloadable template/macro/module sym kinds the same as non-overloadable symbols, just calling `semSym` on it. We need to mirror this behavior in `semOpenSym`; we treat the captured symchoice as a fresh identifier, so if the symbol we find is a template/macro/module, we use that symbol immediately as opposed to waiting for overloads.
* fixes #14522 #22085 #12700 #23132; no range check for uints (#23930)ringabout2024-08-115-9/+37
| | | | | | | | | | fixes #14522 fixes #22085 fixes #12700 fixes #23132 closes https://github.com/nim-lang/Nim/pull/22343 (succeeded by this PR) completes https://github.com/nim-lang/RFCs/issues/175 follow up https://github.com/nim-lang/Nim/pull/12688
* fixes #23914; jsondoc broken in devel (#23916)ringabout2024-08-113-3/+8
| | | | | follows up https://github.com/nim-lang/Nim/pull/23064 fixes #23914
* fixes #23907; Double destroy using proc type alias with a sink (#23909)ringabout2024-08-112-1/+25
| | | fixes #23907
* fixes #23902; Compiler infers sink in return type from auto (#23904)ringabout2024-08-112-3/+11
| | | fixes #23902
* special handlings for nimble packages to shorten function names (#23891)ringabout2024-08-112-29/+45
| | | | | | | | | | | | | | | | | | | If we need keep readabilities for functions' names, we might put the original names in the comments or in the identifiers like what currently has been done. The new nimble having been shipped since Nim 2.0.0 uses a directory ending with a full hash of a commit for cloned repos, the function names are burderen by this. This PR strips these from package paths and prepends "pkg" for readability. Before: raiseNilAccess__OOZOOZOnimbleZpkgs2Zthreading450O2O045288108d1dfa34d5ade5ce4d922af51909c83cebfZthreadingZsmartptrs_u4 After: raiseNilAccess__pkgZthreadingZsmartptrs_u4
* Fixed nimscript docs (#23938)Antonis Geralis2024-08-111-7/+7
|
* bump nimble to include the fix to `nimble dump` (#23918)Juan M Gómez2024-08-101-1/+1
|
* closes #6549; adds a test case (#23929)ringabout2024-08-091-1/+17
| | | closes #6549
* closes #21347; adds a test case (#23917)ringabout2024-08-041-0/+8
| | | closes #21347
* Add a document to toOpenArray proc (#23905)Tomohiro2024-08-012-0/+18
|
* fixes #13391; VM: Can't get address of object (#23903)ringabout2024-07-291-0/+2
| | | fixes #13391
* fixes JS semicolon omissions (#23896)ringabout2024-07-267-11/+11
|
* fixes #23894; succ/pred shouldn't raise OverflowDefect for unsigned integers ↵ringabout2024-07-262-1/+7
| | | | | | | (#23895) fixes #23894 keeps it consistent with `inc`
* implement genericsOpenSym for symchoices (#23873)metagn2024-07-256-25/+122
| | | | | | | | | | fixes #23865 The node flag `nfOpenSym` implemented in #23091 for sym nodes is now also implemented for open symchoices. This means the intended behavior is still achieved when multiple overloads are in scope to be captured, so the issue is fixed. The code for the flag is documented and moved into a helper proc and the experimental switch is now enabled for the compiler test suite.
* Overload resultion with generic variables an inheritance (#23870)Ryan McConnell2024-07-243-46/+117
| | | The test case diff is self explanatory
* bump nimble to 0.16.0 (#23883)Juan M Gómez2024-07-241-1/+1
|
* minor improvement on cgen (#23887)ringabout2024-07-241-4/+2
|
* improve mangling packages version names with checksums (#23888)ringabout2024-07-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | follow up https://github.com/nim-lang/Nim/pull/19821 dights cannot clash with letters 'Z' and 'O' For `threading-0.2.0-288108d1dfa34d5ade5ce4d922af51909c83cebf` Before: raiseNilAccess__OOZOOZOnimbleZpkgs50Zthreading4548O50O4845505656494856d49dfa5152d53ade53ce52d575050af5349574857c5651cebfZthreadingZsmartptrs_u4 After: raiseNilAccess__OOZOOZOnimbleZpkgs2Zthreading450O2O045288108d1dfa34d5ade5ce4d922af51909c83cebfZthreadingZsmartptrs_u4 <del> nimble or something might use `git rev-parse --short HEAD` to shorten the length of package version names ref https://github.com/nim-lang/nimble/pull/913 </del>
* fixes #19171; have `openArray` converted from `ptr UncheckedArray` be ↵Buldram2024-07-242-2/+28
| | | | | | mutable (#23882) Makes `toOpenArray(x: ptr UncheckedArray)` always return a `var openArray` regardless of if `x` is mutable.
* fixes #23867; fixes #23316; rework nimsuggest for ORC (#23879)ringabout2024-07-233-2/+48
| | | | | | | | fixes #23867 fixes #23316 follow up https://github.com/nim-lang/Nim/pull/22805; fixes https://github.com/nim-lang/Nim/issues/22794 in a different method
* turn some sym flag aliases into enums (#23884)ringabout2024-07-231-18/+13
|
* doc,test(times): followup #23861 (#23881)lit2024-07-232-4/+17
| | | followup #23861
* Allocator: Always place free cells into the active chunk and add ↵SirOlaf2024-07-221-21/+96
| | | | | | | | | | | | | | documentation (#23871) Lets single threaded applications benefit from tracking foreign cells as well. After this, `SmallChunk` technically doesn't need to act as a linked list anymore I think, gotta investigate that more though. The likelihood of overflowing `chunk.free` also rises, so to work around that it might make sense to check `foreignCells` instead of adjusting free space or replace free with a counter for the local capacity. For Nim compile I can observe a ~10mb reduction, and smaller ones for other projects.
* fixes #23838: Compilation by MinGW for cpu=i386 with time_t bug (#23876)Ward2024-07-221-1/+1
| | | | Change Time type in std/time_t to `distinct clong` instead of `distinct int32`
* fixes #23869; sink generic typeclass (#23874)Ryan McConnell2024-07-222-2/+28
| | | | | | | Still have to look this over some. We'll see. I put sink in this branch simply because I saw `tyVar` there and for no other reason. In any case the problem appears to be coming from `liftParamType` as it removes the `sink` type from the formals. #23869
* Fix out-of-bounds slicing in std/varints (#23868)Buldram2024-07-222-7/+7
| | | | | | Corrects a slicing mistake in the `std/varints` implementation which caused it to fail when writing large numbers into buffers smaller than 10..13-bytes, now 9-byte buffers are sufficient as the documentation states.
* remove unused field in ConfigRef (#23875)ringabout2024-07-221-1/+0
| | | follow up https://github.com/nim-lang/Nim/pull/14763
* Merge tyUncheckedArray with tySeq in typeRel (#23866)SirOlaf2024-07-202-10/+6
| | | | | | Ref https://github.com/nim-lang/Nim/issues/23836#issuecomment-2233957324 Their types are basically equivalent so they should behave the same way for type relations.