Commit Graph

23097 Commits

Author SHA1 Message Date
Araq
24597320af progress 2026-06-25 13:24:38 +02:00
Araq
4a9424b682 IC: codegen progress 2026-06-25 09:20:23 +02:00
Andreas Rumpf
e75690f414 Merge branch 'devel' into araq-ic-drift-refactor 2026-06-24 23:51:09 +02:00
Andreas Rumpf
4e1dd0b9fc use IC for nimsuggest (#25915) 2026-06-24 21:58:51 +02:00
Araq
79b86f642f IC: more bugfixes 2026-06-24 14:17:10 +02:00
Araq
48568e466c IC: critical fix so that edits do not cause full recompiles for the backend 2026-06-23 23:30:37 +02:00
Miran
d251eaedeb test all packages with ORC (#25930) 2026-06-23 19:30:20 +02:00
ringabout
6eef0cc2d5 fixes #25908; resolves lent enum disambiguation (#25929)
fixes #25908

When an enum identifier is resolved as an `nkSymChoice`, one of the
candidates may come from a loop-local view and carry `tyVar` or
`tyLent`.

Enum disambiguation should compare the underlying enum type only.
Otherwise a pure-enum field can win incorrectly even though the intended
symbol is already present in the choice set.

Keep the `includePureEnum` lookup path for enum-typed expectations so
#23976 still works, but normalize `var`/`lent` only at the symchoice
selection point.
2026-06-23 12:22:29 +02:00
Araq
39e63e9fcc IC: progress 2026-06-23 12:03:29 +02:00
Araq
08e9514c1d added missing test file 2026-06-22 16:13:14 +02:00
Araq
94e30d411c IC related bugfix 2026-06-22 14:39:57 +02:00
Araq
cdb901e174 IC: progress 2026-06-22 13:39:09 +02:00
Araq
46b0555326 cleanups: the .t.nif files are not negotiable, follows Nimony's hexer split design 2026-06-21 08:52:57 +02:00
Araq
abd948296a now async tests work with IC 2026-06-20 23:04:37 +02:00
Araq
9cac2068cf bugfixes 2026-06-20 11:44:34 +02:00
Araq
da2925bae8 bring back liftdestructors.nim to its simpler logic 2026-06-20 10:22:18 +02:00
Araq
8e5ba13fe3 better type keys 2026-06-20 09:53:35 +02:00
Araq
b71d06e2f5 IC: heavy refactoring of the pipelines 2026-06-20 07:59:05 +02:00
Araq
16d9db7cff and more fixes 2026-06-18 23:02:28 +02:00
Araq
b9af129e5f IC: progress 2026-06-18 20:32:48 +02:00
Araq
88c23f8519 IC: big steps forward 2026-06-18 10:56:32 +02:00
Ryan McConnell
f8e470eb57 fix: {.cast(uncheckedAssign).} ineffective across yield in closure iterators (#25916)
closureiters.nim splits a stmt list at yield points, moving post-yield
code into a new state body. When that stmt list was inside a pragma
block like `{.cast(uncheckedAssign).}`, the new state's body was created
as a bare nkStmtList without the wrapper.

Fix: track the enclosing pragma block in the transform context, and wrap
newly-created state bodies in a copy of it when the split occurs inside
one. Added an explicit `nkPragmaBlock` case to
`transformClosureIteratorBody` that saves/restores `ctx.enclosingPragma`
around its body.
2026-06-16 19:15:16 +02:00
Araq
590b35dc89 added test cases 2026-06-16 18:31:52 +02:00
Araq
009f8776e8 IC: type-offers because why not, there is no end in sight 2026-06-16 18:31:21 +02:00
Andreas Rumpf
f5d9e7a207 IC: bugfixes (#25914) 2026-06-15 23:33:16 +02:00
Andreas Rumpf
acb9b3a4f1 IC: precompiled configs and bugfixes (#25913) 2026-06-15 21:20:09 +02:00
Andreas Rumpf
7171e6f01f IC: progress (#25879) 2026-06-14 22:35:06 +02:00
Andreas Rumpf
9d7c0cc683 SSO: add readRawDataStable across all string implementations (#25909)
Companion to readRawData whose pointer stays valid across moves/copies
of the string. Under --strings:sso it promotes a small inline string to
its heap representation; under refc/v2 the data is already heap-resident
so it aliases readRawData.

Uniform `var string` signature on every backend so code can prepare for
--strings:sso without `when declared`.
2026-06-13 19:27:22 +02:00
Aleksei Rybnikov
c292ab987b docs: correct the Delegating bind statements example (fixes #19240) (#25890)
Fixes #19240.

The Manual's "Delegating bind statements" example didn't compile (module
B didn't import A, type `O` wasn't exported, and `x: T` couldn't bind to
`var O`), and once those were fixed it compiled *without* the `bind`
statement — so it didn't demonstrate delegating bind at all.

This replaces it with a minimal example that genuinely requires `bind
init`: `module main` imports A and B but not C, so `init` is not in
scope at the final instantiation of `genericA`; the open `mixin` symbol
fails to resolve without `bind init` forwarding it from module B.
Verified to fail without `bind` and compile with `bind` under Nim
2.2.10.

---
Disclosure: I work with Claude as a co-processor. I understand what I'm
submitting and I verified the example against the compiler myself. If
you prefer human-only contributions, just say so and I'll close without
friction.
2026-06-13 12:54:19 +02:00
ringabout
587f90a816 fixes #22122; Unclear error message for raise of a complex expression (#25899)
fixes  #22122

The commit fixes a bug in Nim's effects checker where raise statements
with case/if expressions (commonly from template expansion) failed to
track exception types from individual branches.
Problem: addRaiseEffect only saw the outermost expression. When a
template like getTransportError(err) expanded to a case expression
raising 3 different exception types, the compiler only registered the
top-level call — missing the branch-level exceptions.
Fix (2 files):
- compiler/sempass2.nim: Added skipHiddenConv to strip implicit type
coercion nodes (nkHiddenStdConv/nkHiddenSubConv) that hide the control
flow structure. Added addRaiseEffectsFromExpr that recursively walks
into case/if/block/stmtlist expressions to find raise effects in each
branch body. Changed the nkRaiseStmt handler to use this new function.
- tests/effects/tcase_raises.nim: Test with templates that expand to
case expressions raising different exception types, verified via
{.raises: [].} pragma.
2026-06-13 10:17:59 +02:00
ringabout
8ad1d106ec fixes #25885; incompleteStruct ignored without importc (#25898)
fixes #25885
2026-06-13 10:17:44 +02:00
ringabout
67707a54b5 fixes #18367 and #21222; using quote inside static block (#25907)
fixes #18367
fixes #21222


1. In vmdef.nim:304, newCtx now sets templInstCounter: new int when it
builds TCtx.
2. vm.nim:1490 — During VM execution of templates, c.templInstCounter is
passed to evalTemplate
3. evaltempl.nim:204 — instID: instID[] dereferences the ref int
4. With a nil templInstCounter, this would crash
5. The same initialization already exists on the semantic side in
sem.nim:787, so this change makes the VM path consistent with the rest
of the compiler.
2026-06-13 07:04:17 +02:00
ringabout
0f751695e4 fixes #25903 and #25904; add closure iterators with error handling (#25905)
fixes #25903
fixes #25904


`nkExceptBranch` can have variable structure depending on the exception
types and it should handle the last node of the `nkExceptBranch`
2026-06-13 07:03:28 +02:00
ringabout
9db9b8ce57 adds regression tests (#25906)
closes #22842, closes #21252, closes #19312, 
closes #16956, closes #16416, closes #14913, closes #13296,
closes #12424, closes #10902, closes #9892, closes #9617
2026-06-13 11:06:51 +08:00
WyattBlue
b44d373b7d adds wasm64 (Memory64) as a first-class target (#25900)
This pull request allows setting `--cpu:wasm64`, allowing wasm64 as a
first class target. This avoids having to set `-cpu:riscv64` as a
workaround. Sane defaults for the emscripten toolchain are also
provided.
2026-06-11 23:49:50 +02:00
Jacek Sieka
7fa006c4e5 fix invalid join (#25896)
can't join a thread that wasn't started (causes random crashes)
2026-06-11 20:24:48 +02:00
Jacek Sieka
1376052519 memalloc: fix forward declarations (#25895)
None of them have side effects / all are gcsafe
2026-06-11 16:13:24 +02:00
Jacek Sieka
13d152a4d1 fix state array constant types (#25893)
else there's a mismatch in the AST for the bracket constructor
2026-06-11 16:12:28 +02:00
Jacek Sieka
c620adcfce astyaml: formatting fixes (#25897)
fix missing indent and newlines here and there
2026-06-11 14:10:42 +02:00
Jacek Sieka
eaa4b342be system: remove unused exception raising code (#25894)
...that otherwise causes an unnecessary raise effect on writeWindows /
echoBinSafe
2026-06-11 10:33:51 +02:00
Ryan McConnell
0448557bfe fix 25778; concept coerces incompatible types (#25781)
I don't like it, but seems like this is correct. Concept type classes
have to behave like other "named" type classes and participate in "bind
once" mechanics or require some weird semantics. As a side note I'm
pretty sure the `tuple` example in the manual explaining this is either
wrong now or has regressed, but I don't think it matters because I doubt
anyone thinks about this feature much.
#25778
2026-06-11 08:17:35 +02:00
ringabout
07685f79e0 implements fallback memfiles on Nintendoswitch (#25891)
fix hightlies failures
2026-06-11 08:15:30 +02:00
ringabout
f5c43ad759 closes #25885; adds a test case (#25892)
closes #25885
2026-06-11 13:07:10 +08:00
Tomohiro
48621c217f adds modifierMode parameter to typeof (#25815)
This PR adds 3 modes to `typeof` to specify how to handle type modifiers
`var`, `sink` and `lent`.

- typeOfModCompatible
Remove or keep type modifiers in the same way as old typeof. That means
keep `sink` but remove `var` and `lent`.
- typeOfModRemoveModifier
  Remove type modifiers.
- typeOfModKeepModifier
  Keep type modifiers.

Related to https://github.com/nim-lang/Nim/pull/25779
https://github.com/nim-lang/Nim/issues/25786
2026-06-09 20:55:30 +02:00
ringabout
4d0663096c Revert "fixes #22122; raise effects for complex expressions" (#25888)
Reverts nim-lang/Nim#25845

```nim
case ecode
of ECONNABORTED, EPERM, ETIMEDOUT, ENOTCONN:
  getConnectionAbortedError(ecode)
of EMFILE, ENFILE, ENOBUFS, ENOMEM:
  getTransportTooManyError(ecode)
else:
  (ref TransportOsError)(code: ecode,
                         msg: "(" & $int(ecode) & ") " & osErrorMsg(ecode))
```

The compiler inserts a hidden conv for the case expression. Perhaps we
can skip hidden convs to inspect the types that are actually raised
2026-06-09 14:46:48 +02:00
ringabout
e942da94b5 fixes #22122; raise effects for complex expressions (#25845)
fixes #22122

The root cause is in the effect tracker: raise was recording the whole
conditional expression as one exception source, so semantic checking
only saw the widened common base type instead of the concrete exception
classes from each branch.
2026-06-08 22:59:16 +02:00
Aleksei Rybnikov
b6842c144d fix(uri): ? operator now appends to existing query string (#25831)
## Summary

Fixes #19782.

The `?` operator in `std/uri` was silently overwriting any query string
already present in the URI. This PR makes it append instead — which
matches the docstring ("Concatenates the query parameters") and the
natural expectation when chaining operations.

**Before:**
```nim
let u = parseUri("https://example.com/foo?existing=1") ? {"bar": "qux"}
echo $u  # https://example.com/foo?bar=qux  (existing=1 lost)
```

**After:**
```nim
let u = parseUri("https://example.com/foo?existing=1") ? {"bar": "qux"}
echo $u  # https://example.com/foo?existing=1&bar=qux
```

## Changes

- `lib/pure/uri.nim`: fix `?` to append with `&` when a query string
already exists; add example to `runnableExamples`
- `tests/stdlib/turi.nim`: two new test cases (append to existing query,
empty params preserve existing)
- `changelog.md`: entry under Standard library changes

## Notes

I work with Claude as a co-processor. I'm 56, came to programming late,
and this is genuinely how I learn and contribute. I understand what I'm
submitting, but I didn't write it alone. If your project prefers
human-only contributions, just say so and I'll close without friction.

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: n0madgang <14005836+n0madgang@users.noreply.github.com>
2026-06-08 22:58:44 +02:00
ringabout
b000d4a32a uses lent for sets (#25882) 2026-06-08 22:57:33 +02:00
Andreas Rumpf
7a5e35c83e fixes #25693; continues the bugfix story (#25876) 2026-06-08 22:54:03 +02:00
ringabout
2d148edeb8 adds a test case for #25872 (#25880) 2026-06-08 22:47:42 +08:00