Commit Graph

22535 Commits

Author SHA1 Message Date
lit
e2bed72b72 doc(tempfiles): update link of getTempDir (#24661)
- tempfiles: update `getTempDir` link... from os.html to appdirs.html
<https://nim-lang.org/docs/appdirs.html#getTempDir>

- ~~nims.md: rm three `std/`, which are out of place~~ (ref
https://github.com/nim-lang/Nim/pull/24661#discussion_r1937293833)
2025-02-03 17:12:44 +08:00
metagn
0861dabfa7 add ambiguous identifier message to generic instantiations (#24646)
fixes #24644

Another option is to include the symbol names and owners in the type
listing as in #24645 but this is a bit verbose.
2025-01-31 08:44:44 +01:00
metagn
647c6687f1 don't mark captured field sym in template as fully used (#24660)
fixes #24657
2025-01-31 08:44:02 +01:00
lit
af5fd3fea3 fix doc format: testament.md (#24654)
- **doc(format): testament: fix `Commands` not regarded as table**

![image](https://github.com/user-attachments/assets/85238dd5-e199-41ca-a8cb-05849415097a)

- **doc(format): testament: row `--target` not splited as columns**

![image](https://github.com/user-attachments/assets/230ec693-c459-4fee-bc57-f3ab6c34a9b6)
2025-01-30 18:05:51 +01:00
Peter Munch-Ellingsen
cab3342a2d Fix check for Nintendo Switch target (#24652)
This should fix ringabouts comment here:
https://github.com/nim-lang/Nim/pull/24639#issuecomment-2615107496

I wasn't aware that `nintendoswitch` and `posix` would be active at the
same time, so I falsely inverted a check.
2025-01-27 16:57:53 +01:00
Leon Lysak
8c3e62e6de Update dom.nim (removeEventListener function) (#24650)
Essentially just an update for the `removeEventListener` function as per
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener
2025-01-27 08:17:58 +01:00
Tomohiro
95b1dda1db Fix parseBiggestUInt to detect overflow (#24649)
With some inputs larger than `BiggestUInt.high`, `parseBiggestUInt` proc
in `parseutils.nim` fails to detect overflow and returns random value.
This is because `rawParseUInt` try to detects overflow with `if prev >
res:` but it doesn't detects the overflow from multiplication.
It is possible that `x *= 10` causes overflow and resulting value is
larger than original value.
Here is example values larger than `BiggestUInt.high` but
`parseBiggestUInt` returns without detecting overflow:
```
22751622367522324480000000
41404969074137497600000000
20701551093035827200000000000000000
22546225502460313600000000000000000
204963831854661632000000000000000000
```

Following code search for values larger than `BiggestUInt.high` and
`parseBiggestUInt` cannot detect overflow:
```nim
import std/[strutils]

const
  # Increase this to extend search range
  NBits = 34'u
  NBitsMax1 = 1'u shl NBits
  NBitsMax = NBitsMax1 - 1'u

  # Increase this when there are too many results and want to see only larger result.
  MinMultiply10 = 14

var nfound = 0
for i in (NBitsMax div 10'u + 1'u) .. NBitsMax:
  var
    x = i
    n10 = 0
  for j in 0 ..< NBits:
    let px = x
    x = (x * 10'u) and NBitsMax
    if x < px:
      break
    inc n10
  if n10 >= MinMultiply10:
    echo "i =   ", i
    echo "uint: ", (i shl (64'u - NBits)), '0'.repeat n10
    inc nfound
    if nfound > 15:
      break

echo "found: ", nfound
```
2025-01-25 15:43:40 +01:00
Peter Munch-Ellingsen
1f9cac1f5c Enable macros to use certain things from the OS module when the target OS is not supported (#24639)
Essentially this PR removes the `{.error.}` pragmas littered around in
the OS module and submodules which prevents them from being imported if
the target OS is not supported. This made it impossible to use certain
supported features of the OS module in macros from a supported host OS.
Instead of the `{.error.}` pragmas the `oscommon` module now has a
constant `supportedSystem` which is false in the cases where the
`{.error.}` pragmas where generated. All procedures which can't be run
by macros is also not declared when `supportedSystem` is false.

It would be possible to create dummy versions of the omitted functions
with an `{.error.}` pragma that would trigger upon their use, but this
is currently not done.

This properly fixes #19414
2025-01-24 13:02:59 +01:00
ringabout
67f9bc2f4b fixes #21923; nimsuggest "outline" output does not list templates (#24643)
fixes #21923

---------

Co-authored-by: Louis Berube <louis.p.berube@gmail.com>
2025-01-24 13:00:08 +01:00
ringabout
d6d28a9c79 fixes #24623; fixes #23692; size pragma only allowed for imported types and enum types (#24640)
fixes #24623
fixes #23692

ref
https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-size-pragma

confines `size` pragma to `enums` and imported `objects` for now

The `typeDefLeftSidePass` carries out the check for pragmas, but the
type is not complete yet. So the `size` pragma checking is postponed at
the final pass.
2025-01-23 20:10:14 +01:00
metagn
6d59680217 don't try to transform objconstr/cast type nodes (#24636)
fixes #24631

[Object
constructors](793baf34ff/compiler/semobjconstr.nim (L462)),
[casts](793baf34ff/compiler/semexprs.nim (L494))
and [type
conversions](793baf34ff/compiler/semexprs.nim (L419))
copy their type nodes verbatim instead of producing semchecked type
nodes. This causes a crash in transf when an untyped expression in the
type node has `nil` type. To deal with this, don't try to transform the
type node in these expressions at all. I couldn't reproduce the problem
with type conversion nodes though so those are unchanged in transf.
2025-01-22 14:08:21 +01:00
ringabout
2f402fcb82 fixes #24630; static openArray backed by seq cannot be passed to another function (#24638)
fixes #24630
2025-01-22 14:05:57 +01:00
metagn
793baf34ff generate destructor in nodestroy proc for explicit destructor call (#24627)
fixes #24626

`createTypeboundOps` in sempass2 is called when generating destructors
for types including for explicit destructor calls, however it blocks
destructors from getting generated in a `nodestroy` proc. This causes
issues when a destructor is explicitly called in a `nodestroy` proc. To
fix this, allow destructors to get generated only for explicit
destructor calls in nodestroy procs.
2025-01-20 10:12:38 +01:00
Antonis Geralis
6481482e0e Optimize storing into uninit locations for arrays and seqs. (#24619) 2025-01-19 16:20:54 +03:00
ringabout
2af9ddc286 revert strictDefs as the default (#24620)
revert https://github.com/nim-lang/Nim/pull/24225

see also https://forum.nim-lang.org/t/12646
2025-01-17 16:08:47 +01:00
ringabout
70d057fcc6 fixes compile crashes with one parameter (#24618)
`{.compile("foo.c").}` makes Nim compiler crash
2025-01-16 15:43:18 +01:00
metagn
8d0e853e0a ignore match errors to expected types of tuple constructor elements (#24611)
fixes #24609

A tuple may have an incompatible expected type if there is a converter
match to it. So the compiler should not error when trying to match the
individual elements in the constructor to the elements of the expected
tuple type, this will be checked when the tuple is entirely constructed
anyway.
2025-01-15 20:01:56 +01:00
metagn
d83ff81695 disable sfml test on osx (#24615)
Tried installing sfml 2 in #24614 but didn't work
2025-01-13 10:10:05 +01:00
ringabout
41c447b5f4 ci: update to ubuntu 22.04 (#24608) 2025-01-09 19:52:03 +08:00
Bilog WEB3
26ed469996 Update changelog_1_2_0.md (#24607) 2025-01-09 18:00:11 +08:00
Loïc Bartoletti
4aff12408c math: Add cumprod and cumproded (#23416)
This pull request adds the `cumproded` function along with its in-place
equivalent, `cumprod`, to the math library. These functions provide
functionality similar to `cumsum` and `cumsummed`, allowing users to
calculate the cumulative sum of elements.

The `cumprod` function computes the cumulative product of elements
in-place, while `cumproded` additionally returns the prod seq.
2025-01-09 09:07:59 +01:00
planetBoy
8ed0a63973 docs fix spelling issues (#24597)
Hey !
I fixed several spelling issues.Glad I could help .
Br, Guayaba221.
2025-01-06 13:48:35 +08:00
ringabout
aeeccee50a fixes #24599; misleading error message with large array bounds (#24601)
fixes #24599
2025-01-05 18:10:36 +01:00
Jacek Sieka
e8bf6af0da fix c_memchr, c_strstr definitions (#24587)
One correct definition is enough
2025-01-02 17:28:35 +01:00
Jacek Sieka
78835562b1 varints: no need for emit (#24585) 2025-01-02 17:26:53 +01:00
ringabout
3dda60a8ce Update copyright year 2025 (#24593) 2024-12-31 18:06:55 +08:00
Skylar Ray
dcc4e07e54 chore: docs fix spelling issues (#24581)
**handle - handles**
**sensitiviy - sensitivity**
2024-12-30 19:40:45 +08:00
futreall
0df351bf50 chore: correct typos docs (#24580) 2024-12-28 16:24:46 +01:00
Antonis Geralis
d3b6dba616 Consider iterator types (#24577)
According to the macros doc nnkIteratorTy trees use the same structure
as nnkProcTy
2024-12-28 09:25:49 +01:00
Antonis Geralis
e1be29942e Support tuple parameter types (#24576) 2024-12-28 08:43:41 +01:00
chloefeal
cd220fe3e1 docs: fix typos (#24573)
Signed-off-by: chloefeal <188809157+chloefeal@users.noreply.github.com>
2024-12-27 19:42:18 +01:00
Jake Leahy
86d6f71f5a Doc search improvements (#24567)
- `/` is now a hotkey to jump to the search
- Search results now are in line with the page (previously on small
screens it would be off centre)
- Jumping to a search result inside the page or via TOC will now hide
the search results (previously the results got in the way)

Example site here: https://tranquil-scone-c159b6.netlify.app/main.html
2024-12-25 14:19:22 +01:00
Jake Leahy
5b9ff963c5 Minor std/strscans improvements (#24566)
#### Removes UnInit warnings when using `scanTuple` 

e.g. this would emit a warning
```nim
import std/strscans

proc main() =
  let (ok, number) = "123".scanTuple()
```

![image](https://github.com/user-attachments/assets/68170ac6-402d-48b0-b8b6-69e71f4b70ae)

#### Error for wrong type now points to the passed in variable

```nim
import std/strscans

var str: string
discard "123".scanf("$i", str)
```

it gave this warning before

![image](https://github.com/user-attachments/assets/096e56d2-0eb5-4c67-9725-25caa97afebd)
now it returns

![image](https://github.com/user-attachments/assets/736a4292-2f56-4cf3-a27a-677045377171)
2024-12-25 09:27:12 +01:00
ringabout
65b26401bc adds a test case (#24565)
closes #19531
2024-12-25 09:26:06 +01:00
Esteban C Borsani
2f127bf99f Improve async stacktraces (#24563)
This makes await point to the caller line instead of asyncmacro. It also
reworks the "Async traceback:" section of the traceback. Follow up PR
#21091 (issue #19931) so it works if there is asynchronous work done.
2024-12-25 09:25:28 +01:00
ringabout
3c4246dd24 fixes #23114; Nim v2 regression emit / asm var param dereference inconsistency (#24547)
fixes #23114

As in https://github.com/nim-lang/Nim/pull/22074, expressions in
bracketed emit are strictly typechecked, this PR applies the same check
for symbols in asm statements in order to keep them consistent.
2024-12-25 09:23:25 +01:00
Tomohiro
fc806710cb Add inline assembler tests for i386, arm, arm64, riscv32 and riscv64 (#24564)
This fixes one error in https://github.com/nim-lang/Nim/issues/24544 .
I tested this on Raspberry Pi Pico (arm) and Raspberry Pi 3(arm64).
It is not tested on i386, riscv32 and riscv64 CPU.
2024-12-24 23:11:19 +08:00
ringabout
e2a306355c adds a test case (#24561)
closes #18616
2024-12-23 21:03:18 +08:00
metagn
5c71fbab30 fix jsonutils with generic sandwiches, don't use strformat (#24560)
fixes #24559

The strformat macros have the problem that they don't capture symbols,
so don't use them in the generic `fromJson` proc here. Also `fromJson`
refers to `jsonTo` before it is declared which doesn't capture it, so
it's now forward declared.
2024-12-23 06:08:46 +01:00
Jake Leahy
6bc52737b3 Make 'field is not accessible' and 'field initialized twice' errors point to the field inside the obj construction (#24557)
Fixes two line infos to make the error's clearer inside editors

- 'field is not accessible' would point to the whole object construction
instead of just the field inside the construction
- 'field initialized twice' would point to the colon instead of the
field
2024-12-22 14:25:36 +01:00
Esteban C Borsani
f29234b40f fixes #23212; Asyncdispatch leaks under --mm:arc (#24556)
Fixes #23212

Inspired by [this chronos
PR](https://github.com/status-im/nim-chronos/pull/243)
2024-12-22 07:56:22 +01:00
ringabout
63c884038d remove zippy data from tarballs (#24551)
fixes https://github.com/nim-lang/nightlies/issues/95
2024-12-20 22:09:29 +01:00
metagn
986ca7dcd4 check if unused import warning is enabled before adding import to stack (#24554)
fixes #24552

Could also implement `{.used.}` for imports but this wouldn't be
backwards compatible. The same problem as #24552 also exists for
`{.hint[XDeclaredButNotUsed].}` but this isn't as much of a problem
since `{.used.}`/`{.push used.}` exist.
2024-12-20 22:09:03 +01:00
Daniel Stuart
50ed43df42 Use long int builtins for risc-v 32-bit targets (#24553)
Solves compilation using riscv32-unknown-elf-gcc, compiler defines
int32_t as long int.
2024-12-20 21:27:37 +03:00
ringabout
ce4304ce97 fixes strictdefs warnings (#24550) 2024-12-20 15:26:30 +01:00
Jake Leahy
f80ce139d5 Make expandMacro show private fields (#24522)
Was debugging with `--expandMacro` and noticed that private fields
weren't exported.
Passes extra flags to the renderer to make them be shown
2024-12-17 18:17:04 +01:00
ringabout
d5c7abe3d2 fixes #17681; enforce codegen for exportc consts (#24546)
fixes #17681
2024-12-17 18:16:34 +01:00
Juan M Gómez
8ce58fab26 Adds skipParentCfg back. Bump nimble to a commit where it doesnt rely in the parent config (#24545) 2024-12-17 18:15:48 +01:00
ringabout
70b3232d3a fixes #24536; fixes nightlies regression caused by nimble update (#24542)
follow up #24537

Because `nimble` is a bundled repo so it is bundled in the tarballs

i.e.
82421fd705/.github/workflows/nightlies.yml (L264)
has bundled `dist/nimble`, but it only copies the data without `.git`.
So in this PR, we ignore bundled nimble repo.
2024-12-17 06:42:17 +01:00
ringabout
81d8c0fc17 fixes #20908; Unknown warnings and hints now give a warning (#24543)
fixes #20908

This PR unifies the treatment of unknown warnings and hints, which now
gives an `warnUnknownNotes` instead of an error.
2024-12-17 06:41:38 +01:00