Commit Graph

22827 Commits

Author SHA1 Message Date
araq
97dfba8222 disabled debug echo 2025-12-11 08:48:44 +01:00
araq
d39f328852 things begin to make sense 2025-12-11 08:31:43 +01:00
araq
4f6e808fca rename 2025-12-10 20:33:10 +01:00
araq
08946a95ee progress 2025-12-10 14:11:08 +01:00
araq
7fd02fc31a progress 2025-12-10 12:31:44 +01:00
Araq
447bf7e198 progress 2025-12-10 00:57:19 +01:00
araq
f77e86de12 progress 2025-12-10 00:07:36 +01:00
araq
39d5ecce1f IC: progress 2025-12-09 13:09:36 +01:00
araq
cf47a29a83 IC: loader: progress 2025-12-07 18:40:38 +01:00
Andreas Rumpf
fa4d79f519 IC: progress (#25339) 2025-12-07 13:07:44 +01:00
elijahr
099ee1ce4a Fixes #25341; Invalid C code for lifecycle hooks for distinct types based on generics (#25342) 2025-12-07 12:59:42 +01:00
Andreas Rumpf
c3a20fa890 IC: progress (#25332) 2025-12-06 11:45:01 +01:00
Yuriy Glukhov
8f8814b495 Fixes #25330 (#25336)
Fixed state optimizer. It did not replace deleted states in
`excLandingState`.
2025-12-05 15:27:38 +01:00
ringabout
0ea5f2625c fixes #25306; Dangling pointers in stack traces with -d:nimStackTraceOverride (#25313)
fixes #25306

```nim
type
  StackTraceEntry* = object ## In debug mode exceptions store the stack trace that led
                            ## to them. A `StackTraceEntry` is a single entry of the
                            ## stack trace.
    procname*: cstring      ## Name of the proc that is currently executing.
    line*: int              ## Line number of the proc that is currently executing.
    filename*: cstring      ## Filename of the proc that is currently executing.
    when NimStackTraceMsgs:
      frameMsg*: string     ## When a stacktrace is generated in a given frame and
                            ## rendered at a later time, we should ensure the stacktrace
                            ## data isn't invalidated; any pointer into PFrame is
                            ## subject to being invalidated so shouldn't be stored.
    when defined(nimStackTraceOverride):
      programCounter*: uint ## Program counter - will be used to get the rest of the info,
                            ## when `$` is called on this type. We can't use
                            ## "cuintptr_t" in here.
      procnameStr*, filenameStr*: string ## GC-ed alternatives to "procname" and "filename"
```
2025-12-05 07:52:35 +01:00
ringabout
5d4829415a fixes #25324; Channel incorrectly takes a sink argument in refc (#25328)
… it performs a deep copy internally

fixes #25324

notes that
> Enabling `-d:nimPreviewSlimSystem` removes the import of
`channels_builtin` in
in the `system` module, which is replaced by
[threading/channels](https://github.com/nim-lang/threading/blob/master/threading/channels.nim).
2025-12-05 00:46:47 +01:00
Ryan McConnell
86bbc73b3a concept patch: inheritance (#25317)
adds some inheritance support

---------

Co-authored-by: Andreas Rumpf <araq4k@proton.me>
2025-12-03 17:51:18 +01:00
ringabout
1da0dc74d9 fixes #22305; Combination of generic destructor and closure fails in certain cases (#25327)
fixes #22305

It seems that the generic type is cached somehow so that no hooks are
instantiated for the generic type. There are only hooks for the
instantiated type. When `lambdalifting` tries to create type bounds for
the generic type, it cannot either find the instantiated hooks or
instantiate the generic hooks since it lacks `SemContext`. It can use
hooks for the instantiated type in this case
2025-12-03 17:29:45 +01:00
Ryan
2d0b62aa51 std: sysatomics: fix use of atomicCompareExchangeN for MSVC (#25325)
`InterlockedCompareExchange64 `(winnt.h) is used instead of gcc atomics
when compiling with MSVC on Windows, but the function signatures are
`InterlockedCompareExchange64(ptr int64, int64, int64)` and
`InterlockedCompareExchange32(ptr int32, int32, int32)` as opposed to
`(ptr T, ptr T, T)` for `__atomic_compare_exchange_n`.

Passing a pointer to the expected value (parameter two) instead of the
value itself causes the comparison to unconditionally fail, with stalls
in threaded code using atomic comparisons.

Fix the function signature for MSVC.

Signed-off-by: Ryan Walklin <ryan@testtoast.com>
2025-12-02 17:07:07 +08:00
Jacek Sieka
91febf1f4c Ensure channels don't leak exception effects (#25318)
The forward declarations cause `Exception` to be inferred - also,
`llrecv` is an internal implementation detail and the type of the
received item is controlled by generics, thus the ValueError raised
there seems out of place for the generic api.
2025-12-01 22:59:26 +01:00
Andreas Rumpf
a773178e2b IC: progress (#25314) 2025-12-01 22:59:12 +01:00
Yuriy Glukhov
6656084004 Fixes #25261 (#25310)
Returning or yielding from a closureiter must restore "external"
exception, but `popCurrentException` from `blockLeaveActions` was
getting in the way. So now `blockLeaveActions` doesn't emit
`popCurrentException` for returns in closureiters. I'm not a fan of this
"abstraction leakage", but don't see a better solution yet. Any input is
much appreciated.

---------

Co-authored-by: Andreas Rumpf <araq4k@proton.me>
2025-11-27 10:09:52 +01:00
Andreas Rumpf
0486a2df51 IC progress (#25283)
bugfix: produce the required nimcache subdir
2025-11-25 12:49:23 +01:00
Peter Munch-Ellingsen
6543040d40 Fixes #25304 proper test for hlo recursion limit (#25305)
The `warnUser` message kind is probably not the right one, but I left it
as a placeholder. It should probably at least warn if not just straight
up throw an error, was very hard to figure out what went wrong without
any indication. The hard coded 300 should possibly also be changed to
`evalTemplateLimit` or the VM call recursion limit or something.
2025-11-21 21:26:43 +01:00
Andreas Rumpf
0f7b378467 system.nim refactorings for IC (#25295)
Generally useful refactoring as it produces better code.
2025-11-19 16:27:31 +01:00
ringabout
46d4079357 use nimKochBootstrap for niminst (#25293)
so that `nimony` won't be required for nightlies. It's annoying to build
`nimony` on each platform, e.g. `std/memfiles` which is used by `nimony`
is not supported by `nintendoswitch`

```
bin/nim compile -f --incremental:off --compileonly --gen_mapping --cc:gcc --skipUserCfg --os:nintendoswitch --cpu:arm64 -d:danger -d:gitHash:cd69f37f3a4fb46468b77b84ccf6aa3225c8895e compiler/nim.nim
```

```
/home/runner/work/nightlies/nightlies/nim/lib/pure/memfiles.nim(107, 40) Error: undeclared identifier: 'MAP_SHARED'
candidates (edit distance, scope distance); see '--spellSuggest': 
 (4, 5): 'freeShared'
```
2025-11-18 20:03:34 +08:00
ringabout
cd69f37f3a Update NimonyStableCommit hash (#25292)
ref
322178d9af

I will add an i386 CI for bootstrapping later
2025-11-18 17:06:28 +08:00
Ryan McConnell
79ddb7d89e concept patch for tyGenericInvocation (#25288)
matching between some generic invocations and equivalent instantiations
did not have a code path
2025-11-15 12:52:16 +01:00
ringabout
7cb8165e75 ref nightlies; Update NimonyStableCommit to a new version (#25289)
596ae916a8
2025-11-15 10:09:57 +01:00
Zoom
b539adf829 std: sysstr cleanup, add docs (#25180)
- Removed redundant `len` and `reserved` sets already performed by prior
`rawNewStringNoInit` calls.
- Reuse `appendChar`
- Removed never used `newOwnedString`
- Added internal `toOwnedCopy`
- Documents differences in impls of internal procs used for
`system.string.setLen`:
  + `strs_v2.setLengthStrV2`:
    - does not set the terminating zero byte when new length is 0
    - does not handle negative new length
  + `sysstr.setLengthStr`:
    - sets the terminating zero byte when new length is 0
    - bounds negative new length to 0
2025-11-15 08:42:10 +01:00
Zoom
01c084077e std: sysstr refactor (#25185)
Continuation of #25180. This one refactors the sequence routines.

Preparation for extending with new routines.

Mostly removes repeating code to simplify debugging.

Removes:
 - `incrSeqV2` superseded by `incrSeqV3`,
 - `setLengthSeq` superseded by `setLengthSeqV2`

Note comment on line 338, acknowledging that implementation of
`setLenUninit` from #25022 does zero the new memory in this branch,
having been copied from `setLengthSeqV2`. This PR does not fix this.
2025-11-15 08:41:57 +01:00
lit
39be9b981d fixes #25227; crash when codegen user-defined tuple iterate (#25228)
fixes #25227
2025-11-14 18:43:13 +01:00
ringabout
9becd1453d fixes #25284; .global initialization inside method hoisted to preInitProc (#25285)
fixes #25284

```nim
proc m2()  =
  let v {.global, used.}: string = f2(f2("123"))
```

transform lifted `.global`statements in the top level scope
2025-11-14 16:20:42 +01:00
Andreas Rumpf
f608e109c9 massive refactoring for IC (#25282)
TODO:

- [ ] test writing of .nif files
- [x] implement loading of fields in PType/PSym that might not have been
loaded
- [ ] implement interface logic
- [ ] implement pragma "replays"
- [ ] implement special logic for `converter`
- [ ] implement special logic for `method`
- [ ] test the logic holds up for `export`
- [ ] implement logic to free the memory of PSym/PType if memory
pressure is high
- [ ] implement logic to close memory mapped files if too many are open.

---------

Co-authored-by: demotomohiro <gpuppur@gmail.com>
Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
Co-authored-by: Jacek Sieka <arnetheduck@gmail.com>
2025-11-13 21:31:24 +01:00
Andreas Rumpf
4c6d9b6068 nimsuggest tester: remove PCRE dependency (#25279)
Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
2025-11-13 09:07:31 +01:00
Andreas Rumpf
5da72efbde VM: refactoring [backport] (#25280)
Note to @narimiran backport because IC requires it.
2025-11-12 19:04:21 +01:00
ringabout
d5549a3c65 updates to macos-15 (#25278)
ref https://github.com/actions/runner-images/issues/13046
2025-11-12 20:33:26 +08:00
ringabout
a57b6d8406 uses csources_v3 (#25273) 2025-11-11 14:00:47 +01:00
lit
2679b3221c fixes #19846; std/unicode.strip trailing big chars (#25274)
fixes #19846
2025-11-11 12:01:07 +01:00
Ryan McConnell
cc4c7377b2 silence mass dump of BareExcept when using unittest (#25260)
Seems better to change it to `CatchableError` instead?
2025-11-10 07:27:50 +01:00
ringabout
92468e99f7 fixes #25265; fixes #23453; Unable to build Nim 2.2.6 tools from source (#25269)
fixes #25265;
fixes #23453

`(addr deref (ptr object))` generated weak typedesc before, which causes
problems for old GCC versions. As a bonus, by generating a typedesc for
`deref (ptr object)`, it also fixes #23453
2025-11-08 06:04:05 +01:00
metagn
839cbeb371 js: replace push.apply with for loop for string add [backport] (#25267)
While `a.push.apply(a, b)` is better for performance than the previous
`a = a.concat(b)` due to the fact that it doesn't create a new array,
there is a pretty big problem with it: depending on the JS engine, if
the second array is too long, it can [cause a
crash](https://tanaikech.github.io/2020/04/20/limitation-of-array.prototype.push.apply-under-v8-for-google-apps-script/)
due to the function `push` taking too many arguments. This has
unfortunately been what the codegen produces since 1.4.0 (commit
707367e1ca).

So string addition is now moved to a compilerproc that just uses a `for`
loop. From what I can tell this is the most compatible and the fastest.
Only potential problem compared to `concat` etc is with aliasing, i.e.
adding an array to itself, but I'm guessing it's enough that the length
from before the iteration is used, since it can only grow. The test
checks for aliased nim strings but I don't know if there's an extra
protection for them.
2025-11-07 20:19:50 +08:00
Andreas Rumpf
809662a228 VM: optimize 'return' slots; saves millions of node allocations for N… (#25266)
…imbus
2025-11-07 11:05:13 +01:00
ringabout
6f73094263 fixes #25251; SIGBUS with iterator over const Table lookup - premature temporary destruction (#25255)
fixes #25251

enforce a copy if the arg is a deref of a lent pointer since the arg
could be a temporary that will go out of scope
2025-11-07 10:06:05 +01:00
Jacek Sieka
861ebc0f19 Add heaptrack support (#25257)
This PR, courtesy of @NagyZoltanPeter
(https://github.com/waku-org/nwaku/pull/3522) adds the ability to track
memory allocations in a program suitable for use with
[heaptrack](https://github.com/KDE/heaptrack).

By passing `-d:heaptrack --debugger:native` to compilation, calls to
heaptrack will be injected when memory is being allocated and released -
unlike `-d:useMalloc` this strategy also works with `refc` and the
default memory pool.

See https://github.com/KDE/heaptrack for usage examples. The resulting
binary needs to be run with `heaptrack` and with the shared
`libheaptrack_preload.so` in the `LD_LIBRARY_PATH`.
2025-11-06 17:33:52 +01:00
ringabout
1d08c4e241 fixes #25263; provides a new switch mangle:nim/cpp for debug name mangling (#25264)
fixes #25263

- [x] documentation and changelogs
2025-11-06 16:41:13 +01:00
Andreas Rumpf
cfefd1d95b produces vastly better error messages for implicit --import and --inc… (#25258)
…lude configuration options
2025-11-04 17:54:23 +01:00
ringabout
d54b5f3ae1 fixes #25252; Unexpected ambiguous call with fields over object with default fields (#25256)
fixes #25252
2025-11-04 20:08:07 +08:00
Tomohiro
5079074b1a uses newer Nimony (#25249)
Old Nimony has unfixed issue
https://github.com/nim-lang/nimony/issues/1313.
So https://github.com/nim-lang/Nim/pull/25243 doesn't work correctly
with float literal `-0.0`.
This PR updates the Nimony that fixed the issue.
2025-10-31 16:59:38 +01:00
Yuriy Glukhov
99a222d63d Respect noinit for generic types (#25250) 2025-10-31 16:59:24 +01:00
Miran
3e9a66599a bump the shipped version of Atlas (#25248) 2025-10-30 20:30:28 +01:00