Commit Graph

22650 Commits

Author SHA1 Message Date
bptato
a5ade112cb Add missing error handling in getAppFilename (#25017)
readlink can return -1, e.g. if procfs isn't mounted in a Linux chroot.
(At least that's how I found this.)

(cherry picked from commit b6491e7de5)
2025-06-27 13:43:34 +02:00
metagn
5e17c88416 fix generic converter subtype match regression (#25015)
fixes #25014

`implicitConv` tries to instantiate the supertype to convert to,
previously the bindings of `m` was shared with the bindings of the
converter but now an isolated match `convMatch` holds the bindings, so
`convMatch` is now used in the call to `implicitConv` instead of `m` so
that its bindings are used when instantiating the supertype.

(cherry picked from commit 97a6f42b56)
2025-06-27 13:43:16 +02:00
metagn
f003664a14 fix regression with enum types wrongly matching [backport:2.2] (#25010)
fixes #25009

Introduced by #24176, when matching a set type to another, if the given
set is a constructor and the element types match worse than a generic
match (which includes the case with no match), the match is always set
to a convertible match, without checking that it is at least a
convertible match. This is fixed by checking this.

(cherry picked from commit 334848f3ae)
2025-06-23 14:04:02 +02:00
Jacek Sieka
3d634911b8 Ensure that gc interface remains non-raising (#25006)
GC_fullCollect in particular has an annoying `Exception` effect

(cherry picked from commit aba9361510)
2025-06-18 16:14:44 +02:00
ringabout
1f205a0f10 fixes #24996; Crash on marking destroy hook as .error (#25002)
fixes #24996

uses the lineinfos of `dest` is `ri` is not available (e.g. `=destroy`
doesn't have a second parameter)

(cherry picked from commit c22bfe6bc0)
2025-06-16 22:37:55 +02:00
metagn
62df0b7586 loosen compiler assert for ident node in dotcall matching [backport:2.2] (#25003)
fixes #25000

A failed match on `nfDotField` tries to assert that the name of the dot
field is an identifier node. I am not exactly sure how but at some point
typed generics causes an `nfDotField` call to contain a symchoice for
the field name. The compiler does not use the fact that the field name
is an identifier, so the assert is loosened to allow any identifier-like
node kind. Could also investigate why the symchoice gets created, my
guess is that typed generics detects that the match fails but still
sends it through generic prechecking and doesn't remove the
`nfDotField`, which is harmless and it might cause more trouble to work
around it.

(cherry picked from commit 8e5ed5dbb7)
2025-06-16 22:37:38 +02:00
metagn
d65a0a3144 don't set sym of generic param type value to generic param sym (#24995)
fixes #23713

`linkTo` normally sets the sym of the type as well as the type of the
sym, but this is not wanted for custom pragmas as it would look up the
definition of the generic param and not the definition of its value. I
don't see a practical use for this either.

(cherry picked from commit 7701b3c7e6)
2025-06-16 09:29:34 +02:00
ringabout
58d4945c1c closes #24992; adds a test case (#24993)
closes #24992

(cherry picked from commit 151b903172)
2025-06-16 09:29:25 +02:00
metagn
1c89ae6684 use windows latest for docs CI (#24991)
2019 is currently browned out

(cherry picked from commit 56bb451c6d)
2025-06-16 09:29:11 +02:00
ringabout
7fdbdb2f20 fixes #24974; SIGSEGV when raising Defect/doAssert (#24985)
fixes #24974

requires `result` initializations when encountering unreachable code
(e.g. `quit`)

(cherry picked from commit 638a8bf84d)
2025-06-11 06:49:05 +02:00
ringabout
11fc6962ae fixes #24981; the length of the seq changed of procGloals (#24984)
fxies #24981

`m.g.graph.procGlobals` could change because the right side of `.global`
assignment (e.g. `let a {.global.} = g(T)`) may trigger injections for
unhandled procs

(cherry picked from commit ffb993d5bd)
2025-06-10 06:31:46 +02:00
Amjad Ben Hedhili
1b49765122 [Docs] Improve scrollbars (#24971)
Follow dark/light modes.

(cherry picked from commit 9d0c0b89f2)
2025-06-10 06:31:39 +02:00
Eugene Kabanov
c55ee7a191 Fix FreeBSD getThreadId() should use different syscall definition for 64bit platforms. (#24977)
(cherry picked from commit 7a53db6874)
2025-06-06 08:33:07 +02:00
Andreas Rumpf
0022ddb271 make mangled module names shorter (#24976)
(cherry picked from commit dd7cecdbd4)
2025-06-06 08:32:58 +02:00
Amjad Ben Hedhili
7d6695b51f Fix docs sidebar truncated (#24970)
* Regression after #24927

(cherry picked from commit f80a076588)
2025-06-03 07:35:02 +02:00
metagn
f209041be0 implement setter fallback for subscripts (#24872)
follows up #24871

For subscript assignments, if an overload of `[]=`/`{}=` is not found,
the LHS checks for overloads of `[]`/`{}` as a fallback, similar to what
field setters do since #24871. This is accomplished by just compiling
the LHS if the assignment overloads fail. This has the side effect that
the error messages are different now, instead of displaying the
overloads of `[]=`/`{}=` that did not match, it will display the ones
for `[]`/`{}` instead. This could be fixed by checking for `efLValue`
when giving the error messages for `[]`/`{}` but this is not done here.

The code for `[]` subscripts is a little different because of the
`mArrGet`/`mArrPut` overloads that always match. If the `mArrPut`
overload matches without a builtin subscript behavior for the LHS then
it calls `semAsgn` again with `mode = noOverloadedSubscript`. Before
this meant "fail to compile" but now it means "try to compile the LHS as
normal", in both cases the overloads of `[]=` are not considered again.

(cherry picked from commit 8752392838)
2025-05-26 10:13:49 +02:00
ringabout
25a13ad0e5 fixes #4594; disallow {.global.} uses local vars for basic expressions (#24961)
fixes #4594

(cherry picked from commit a09da96c65)
2025-05-26 10:13:41 +02:00
ringabout
975ca268f0 fixes #24940; fixes #17552; lifts {.global.} in injectDestructorCalls (#24962)
fixes #24940
fixes #17552

Collects `{.global.}` (i.e. if it was changed into a hook call: `=copy`,
`=sink`) in `injectDestructorCalls` and generates it in the init
sections in cgen

(cherry picked from commit 3c0446b082)
2025-05-26 10:13:29 +02:00
ringabout
3fd9c986f6 rework nimOrcLeakDetector (#24958)
ref https://github.com/nim-lang/Nim/issues/22273#issuecomment-2888931920

(cherry picked from commit c3f64fb127)
2025-05-26 10:13:07 +02:00
Andreas Rumpf
17e0dae12f fixes #4851 [backport] (#24954)
(cherry picked from commit 1e602490e9)
2025-05-19 17:48:22 +02:00
metagn
8120d329ee generate let _ = to fully unpack partial tuple unpacking assignment for arc (#24948)
fixes #24947

When injectdestructors detects that a variable is a tuple unpacking temp
(i.e. it is an `skTemp`, is not a cursor, and has tuple type) it does
not generate a destructor for it and only generates sink/bit assignments
for its components. However the reason it does not generate a destructor
is that it expects it to be fully unpacked, this is true for unpackings
in for loops but not for tuple unpacking assignments which supports `_`
since #22537. Tuple unpacking definitions for `var`/`let`/`const` do not
generate `skTemp` and use the same symbol kind as the definition so they
did not have this problem.

To keep this compatible, the `_` parts of the tuple unpacking
assignments are now not ignored and unpacked into `let _ = ...`, which
generates its own destructor. Another option might be to use `skLet`
instead of `skTemp` but this might cause changes to behavior like
additional copies, I am not sure about this though.

(cherry picked from commit 71c5a4f72c)
2025-05-19 17:48:15 +02:00
ringabout
832eb7e2eb adds nimPreviewCStringComparisons for cstring comparisons (#24946)
todo: We can also give a deprecation message for `ltPtr`/`lePtr`
matching for cstring in `magicsAfterOverloadResolution`

follow up https://github.com/nim-lang/Nim/pull/24942

(cherry picked from commit ade500b2cb)
2025-05-19 17:48:07 +02:00
Niklas Kröger
13752aba99 Fix extra newline from nimpretty when used with --stdin (#24951)
Using `echo` to print file contents to stdout automatically adds a
newline at the end of the file contents. When using nimpretty to auto
format files on save in some editors which replace the file contents
with the formatted ones this means that with every save/format operation
an additional newline is added to the end of the file. Using
`stdout.write` does not automatically add a newline at the end
preventing this issue.

Fixes #24950

(cherry picked from commit c1e6cf812f)
2025-05-19 17:48:01 +02:00
c-blake
9cfc3399bc Maybe close https://github.com/nim-lang/Nim/issues/24932 by simply (#24945)
explaining why the result may not be so surprising. Clean-up of stray
whitespace and insert of missing "in" along for the ride.

It's just not always faster or slower than `Table`. The difference
depends upon many factors such as (at least!): A) how much (if anything
- for `int` keys it is nothing) hash-comparison before `==` comparison
saves B) how much resizing happens (which may even vary from run to run
if end users are allowed to provide scale guess input), C) how much
comparison happens at all (i.e., table density), D) how much space/size
matters - like how close to a specific deployment "available" cache size
the table is.

If we want, we could add a sentence suggesting performance fans also try
`Table`, but the kind of low-level nature of the explanation strikes me
as already along those lines.

(cherry picked from commit 091fb5057b)
2025-05-12 14:21:43 +02:00
ringabout
b10ebc8d17 fixes broken discriminators of float types by disabling it (#24938)
```nim
type
  Case = object
    case x: float
    of 1.0:
      id: int
    else:
      ta: float
```

It segfaults with `fatal error: invalid kind for firstOrd(tyFloat)`

It was caused by https://github.com/nim-lang/Nim/pull/12591 and has
affected discriminators of float types since 1.2.x

I think no one is using discriminators of float types anyway so I simply
disable it like what was done to discriminators of string types (ref
https://github.com/nim-lang/Nim/pull/15080)

ref https://github.com/nim-lang/nimony/pull/1069

(cherry picked from commit d2fee7dbab)
2025-05-12 14:21:35 +02:00
Juan M Gómez
706d1264af Initial implementation for nimsuggest import support (#24937)
Co-authored-by: Andreas Rumpf <araq4k@proton.me>
(cherry picked from commit 8080610248)
2025-05-12 14:21:27 +02:00
ringabout
6c94f456c7 rework tags (#24944)
recent ctags changes: https://github.com/nim-lang/Nim/pull/24317
ref https://forum.nim-lang.org/t/12879

(cherry picked from commit 6c2f78a19f)
2025-05-12 14:21:20 +02:00
bptato
cebaa87a16 Correct nfds_t size on Android (#24647)
Turns out bionic uses an unsigned int (unlike other Linux libcs).

(See
<https://android.googlesource.com/platform/bionic/+/master/libc/include/poll.h>.)

(cherry picked from commit 6f5e5811fc)
2025-05-12 14:20:47 +02:00
ringabout
ee916f051b fixes #24941; missing < (less than), cmp for cstring (#24942)
fixes #24941

now `cmp` can select the correct version of cstring comparsions

(cherry picked from commit 42a4adb4a5)
2025-05-12 14:20:32 +02:00
Amjad Ben Hedhili
d89fd45b9e Add min/max overloads with comparison functions (#23595)
`min`, `max`, `minmax`, `minIndex` and `maxIndex`

(cherry picked from commit 59ceff4f1a)
2025-05-06 16:06:32 +02:00
ringabout
11fd7c045e improvements for semdata (#24933)
(cherry picked from commit b50ab7a5c9)
2025-05-06 16:04:54 +02:00
ringabout
ea51ca8d25 fixes #21975; Pragma block disabling warning has effect beyond block (#24934)
fixes  #21975

(cherry picked from commit 433b725cbb)
2025-05-06 16:04:49 +02:00
metagn
c385fcb6be bring back id table algorithm instead of std table [backport:2.2] (#24930)
refs #24929, partially reverts #23403

Instead of using `Table[ItemId, T]`, the old algorithm is brought back
into `TIdTable[T]` to prevent a performance regression. The inheritance
removal from #23403 still holds, only `ItemId`s are stored.

(cherry picked from commit 82553384d1)
2025-05-06 16:04:43 +02:00
Amjad Ben Hedhili
39757d421e Remove horizontal scrolling on mobile (#24927)
(cherry picked from commit 8b82f5de38)
2025-05-06 16:04:37 +02:00
narimiran
a35b5fb813 Revert "update proc type recursion errors after merge (#24897)"
This reverts commit 238a4db3d9.
2025-05-05 10:32:44 +02:00
ringabout
96a02f1982 fixes #23355; pop optionStack when exiting scopes (#24926)
fixes #23355

(cherry picked from commit 98ec87d65e)
2025-05-05 08:20:55 +02:00
ringabout
c1fbde1e5a fixes address of sink parameters (#24924)
In `semExprWithType`: `if result.typ.kind in {tyVar, tyLent}: result =
newDeref(result)` derefed `var`/`lent`. Since it is not done for `sink`,
we need to skip `tySink` in the corresponding procs

(cherry picked from commit f56568d851)
2025-05-05 08:20:45 +02:00
Ryan McConnell
c5030c8bc6 Fix warning[Uninit] triggers in strutils (#24921)
(cherry picked from commit b5b7a127fd)
2025-05-05 08:20:37 +02:00
Alfred Morgan
d5e8e5d985 Patch 24922 (#24923)
(cherry picked from commit b61a614e8a)
2025-05-05 08:20:07 +02:00
ringabout
0bdc4434e0 don't warn/error symbols in semGenericStmt/templates (#24907)
fixes #24905
fixes #24903
fixes https://github.com/nim-lang/Nim/issues/11805
fixes https://github.com/nim-lang/Nim/issues/15650

In the first phase of generic checking, we cannot warn/error symbols
because they can belong a false branch of `when` or there is a
`push/pop` options using open symbols. So we cannot decide whether to
warn/error or not

(cherry picked from commit 0506d5b973)
2025-05-05 08:19:11 +02:00
Esteban C Borsani
b67f7fab64 asyncnet ssl overhaul (#24896)
Fixes #24895

- Remove all  bio handling
- Remove all `sendPendingSslData` which only seems to make things work
by chance
- Wrap the client socket on `acceptAddr` (std/net does this)
- Do the SSL handshake on accept (std/net does this)

The only concern is if addWrite/addRead works well on Windows.

(cherry picked from commit 8518cf079f)
2025-05-05 08:19:02 +02:00
lit
d9be82d381 fix(js): nonvar destructor was disallowed; closes #24914 (#24915)
(cherry picked from commit d7b1f0a99a)
2025-05-05 08:17:57 +02:00
Tomohiro
f81b83df79 changes FileHandle type on Windows (#24910)
On windows, `HANDLE` type values are converted to `syncio.FileHandle` in
`lib/std/syncio.nim`, `lib/pure/memfiles.nim` and `lib/pure/osproc.nim`.
`HANDLE` type is `void *` on Windows and its size is larger then `cint`.

https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types

This PR change `syncio.FileHandle` type so that converting `HANDLE` type
to `syncio.FileHandle` doesn't lose bits.

We can keep `FileHandle` unchanged and change some of parameter/return
type from `FileHandle` to an type same size to `HANDLE`, but it is
breaking change.

(cherry picked from commit eea4ce0e2c)
2025-05-05 08:17:49 +02:00
metagn
939682eba0 fix generic converter regression with var/subtype args (#24902)
refs #24867,
https://github.com/nim-lang/Nim/pull/24867#issuecomment-2821315971

The argument node of the converter can be wrapped in [hidden `addr` or
subtype conversion
nodes](dc100c5caa/compiler/sigmatch.nim (L2327-L2335))
which have to be skipped when matching the type again, since the type of
the node is the uninstantiated type taken from the proc parameter.

(cherry picked from commit 8c9a645bdf)
2025-05-05 08:17:43 +02:00
Ryan McConnell
19f620c934 Add tySet to concept matching (#24908)
(cherry picked from commit 5dcfd8d7bb)
2025-05-05 08:17:35 +02:00
metagn
5d20ae6098 whitelist prev types to reuse in newOrPrevType (#24899)
fixes #24898

A type is only overwritten if it is definitely a forward type, partial
object (symbol marked `sfForward`) or a magic type. Maybe worse for
performance but should be more correct. Another option might be to
provide a different value for `prev` for the `preserveSym` case but then
we cannot easily ignore only nominal type nodes.

(cherry picked from commit d966ee3fc3)
2025-05-05 08:16:57 +02:00
narimiran
13a0e1a004 bump NimVersion to 2.2.5 2025-04-22 16:25:52 +02:00
narimiran
f7145dd26e Revert "leave type section symbols unchanged on resem, fix overly general double semcheck for forward types (#24888)"
This reverts commit cfe89097e7.
v2.2.4
2025-04-21 23:07:52 +02:00
narimiran
1db543e8b2 bump NimVersion to 2.2.4 2025-04-21 19:10:12 +02:00
metagn
238a4db3d9 update proc type recursion errors after merge (#24897)
refs #24893, refs #24888

(cherry picked from commit dc100c5caa)
2025-04-21 19:09:52 +02:00