Commit Graph

22692 Commits

Author SHA1 Message Date
Esteban C Borsani
fbdc9a4c19 fixes #25023; Asyncnet accept leaks socket on SSL error; Regression in devel (#25024)
Fixes #25023

Revert the acceptAddr #24896 change. SSL_accept is no longer explicitly
called.
2025-07-01 09:52:37 +02:00
Zoom
6bdb069a66 [docs]: warning for long, culong being OS-dependent (#25012)
Docs are routinely compiled on a different OS so often don't reflect
reality of CT-conditionals.

I bet there's a few of other places like this in the stdlib.
2025-06-27 10:49:02 +02:00
ringabout
7e6fa9e2d6 fixes #23564; hasCustomPragma skips alises types (#24994)
fixes #23564

perhaps handle generic aliases (tyGenericInst for aliases types) if
needed
2025-06-27 10:18:12 +02:00
ringabout
3ce38f2959 fixes #24997; {.global.} variable in recursive function (#25016)
fixes #24997

handles functions in recursive order
2025-06-27 10:17:16 +02:00
bptato
b6491e7de5 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.)
2025-06-25 23:21:56 +02:00
metagn
97a6f42b56 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.
2025-06-25 21:42:26 +08:00
metagn
334848f3ae 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.
2025-06-21 23:25:04 +02:00
Jacek Sieka
aba9361510 Ensure that gc interface remains non-raising (#25006)
GC_fullCollect in particular has an annoying `Exception` effect
2025-06-18 14:38:01 +02:00
ringabout
c22bfe6bc0 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)
2025-06-16 21:50:06 +02:00
metagn
8e5ed5dbb7 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.
2025-06-16 19:22:23 +02:00
metagn
7701b3c7e6 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.
2025-06-13 00:03:02 +02:00
ringabout
151b903172 closes #24992; adds a test case (#24993)
closes #24992
2025-06-12 21:47:41 +08:00
metagn
56bb451c6d use windows latest for docs CI (#24991)
2019 is currently browned out
2025-06-11 19:45:11 +08:00
ringabout
638a8bf84d fixes #24974; SIGSEGV when raising Defect/doAssert (#24985)
fixes #24974

requires `result` initializations when encountering unreachable code
(e.g. `quit`)
2025-06-10 14:12:12 +02:00
ringabout
ffb993d5bd 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
2025-06-09 20:53:40 +02:00
Andreas Rumpf
d27c2159fa make 'nim nif' atomic (#24980) 2025-06-08 19:03:46 +02:00
Andreas Rumpf
4fbf538b66 nifgen: bugfix (#24979) 2025-06-06 15:36:31 +02:00
Amjad Ben Hedhili
9d0c0b89f2 [Docs] Improve scrollbars (#24971)
Follow dark/light modes.
2025-06-06 15:08:47 +02:00
Eugene Kabanov
7a53db6874 Fix FreeBSD getThreadId() should use different syscall definition for 64bit platforms. (#24977) 2025-06-05 14:30:07 +02:00
Andreas Rumpf
dd7cecdbd4 make mangled module names shorter (#24976) 2025-06-05 08:34:52 +02:00
Alfred Morgan
807840dc5b Patch 24922 (#24972)
fixed #24922 missing possix_fallocate for openbsd
2025-05-31 15:26:41 +02:00
Amjad Ben Hedhili
f80a076588 Fix docs sidebar truncated (#24970)
* Regression after #24927
2025-05-31 15:26:04 +02:00
ringabout
db5973361f bundles nimony (#24968)
follow up https://github.com/nim-lang/Nim/pull/24966
https://github.com/nim-lang/Nim/pull/21702

So it appears in the nightlies tars and can be installed by choosenim
2025-05-27 11:45:28 +02:00
Andreas Rumpf
241edaf0c0 WIP: adds NIF code generator for interop with Nimony (#24966) 2025-05-26 15:42:19 +02:00
metagn
8752392838 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.
2025-05-23 16:19:13 +02:00
ringabout
a09da96c65 fixes #4594; disallow {.global.} uses local vars for basic expressions (#24961)
fixes #4594
2025-05-23 16:16:57 +02:00
ringabout
3c0446b082 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
2025-05-23 16:15:55 +02:00
ringabout
c3f64fb127 rework nimOrcLeakDetector (#24958)
ref https://github.com/nim-lang/Nim/issues/22273#issuecomment-2888931920
2025-05-19 21:40:35 +02:00
metagn
e855019f84 add STRING_LITERAL macro back to nimbase.h for compatibility (#24957)
refs #24956, refs #24302
2025-05-17 18:37:02 +02:00
Andreas Rumpf
1e602490e9 fixes #4851 [backport] (#24954) 2025-05-16 09:44:13 +02:00
metagn
71c5a4f72c 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.
2025-05-15 09:32:10 +02:00
ringabout
ade500b2cb 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
2025-05-14 21:31:53 +02:00
Niklas Kröger
c1e6cf812f 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
2025-05-14 21:31:09 +02:00
c-blake
091fb5057b 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.
2025-05-11 06:44:03 +02:00
ringabout
d2fee7dbab 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
2025-05-11 06:42:27 +02:00
Juan M Gómez
8080610248 Initial implementation for nimsuggest import support (#24937)
Co-authored-by: Andreas Rumpf <araq4k@proton.me>
2025-05-11 06:41:09 +02:00
ringabout
6c2f78a19f rework tags (#24944)
recent ctags changes: https://github.com/nim-lang/Nim/pull/24317
ref https://forum.nim-lang.org/t/12879
2025-05-11 06:40:46 +02:00
bptato
6f5e5811fc 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>.)
2025-05-10 13:26:00 +02:00
ringabout
42a4adb4a5 fixes #24941; missing < (less than), cmp for cstring (#24942)
fixes #24941

now `cmp` can select the correct version of cstring comparsions
2025-05-10 08:26:21 +02:00
Amjad Ben Hedhili
59ceff4f1a Add min/max overloads with comparison functions (#23595)
`min`, `max`, `minmax`, `minIndex` and `maxIndex`
2025-05-06 14:09:03 +02:00
ringabout
b50ab7a5c9 improvements for semdata (#24933) 2025-05-06 09:46:45 +02:00
ringabout
433b725cbb fixes #21975; Pragma block disabling warning has effect beyond block (#24934)
fixes  #21975
2025-05-06 09:46:18 +02:00
metagn
82553384d1 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.
2025-05-06 09:36:20 +02:00
Amjad Ben Hedhili
8b82f5de38 Remove horizontal scrolling on mobile (#24927) 2025-05-05 08:17:36 +02:00
ringabout
98ec87d65e fixes #23355; pop optionStack when exiting scopes (#24926)
fixes #23355
2025-05-04 03:29:59 +02:00
ringabout
f56568d851 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
2025-05-01 07:49:46 +02:00
Ryan McConnell
b5b7a127fd Fix warning[Uninit] triggers in strutils (#24921) 2025-04-30 23:17:11 +08:00
Alfred Morgan
b61a614e8a Patch 24922 (#24923) 2025-04-30 13:00:23 +02:00
ringabout
0506d5b973 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
2025-04-29 11:08:10 +02:00
Esteban C Borsani
8518cf079f 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.
2025-04-29 11:07:01 +02:00