Commit Graph

21745 Commits

Author SHA1 Message Date
ringabout
112e274804 switch on 2023-12-11 14:12:55 +00:00
ringabout
f1a7bfce47 switch on 2023-12-11 14:12:47 +00:00
ringabout
68bf6c7f93 what's problem os cancelled CI 2023-12-11 11:00:02 +00:00
ringabout
7cd431804b test CI 2023-12-11 09:07:41 +00:00
ringabout
01388dc816 Merge branch 'devel' into pr_string_v3 2023-12-11 13:16:03 +08:00
ringabout
bee9baa8bf reprieve IC 2023-12-09 11:56:17 +00:00
ringabout
147621ec21 fixes a critical issue 2023-12-09 02:41:05 +00:00
ringabout
5bde480596 workaround a cstring conversion bug 2023-12-09 02:34:22 +00:00
ringabout
33f911e691 fixes C++ compilation 2023-12-08 14:13:21 +00:00
ringabout
ec03e476d5 fixes more problems 2023-12-08 08:41:16 +00:00
ringabout
4adb79f7cb a small fix 2023-12-08 07:29:36 +00:00
ringabout
1da417b818 tests nimSeqsV3 2023-12-08 07:26:32 +00:00
ringabout
7ef0f43f35 basic examples work now 2023-12-08 07:04:15 +00:00
Jake Leahy
0a7094450e Only suggest symbols that could be pragmas when typing a pragma (#23040)
Currently pragmas just fall through to `suggestSentinel` and show
everything which isn't very useful. Now it filters for symbols that
could be pragmas (templates with `{.pragma.}`, macros, user pragmas) and
only shows them
2023-12-07 23:05:41 +01:00
ringabout
da277cf1b8 more fixes 2023-12-07 14:47:51 +00:00
ringabout
cb172328ba simple cases compile 2023-12-07 13:56:33 +00:00
ringabout
9af21cf719 progress 2023-12-07 12:53:06 +00:00
Jake Leahy
4fdc6c49bd Don't process a user pragma if its invalid (#23041)
When running `check`/`suggest` in a file with an invalid user pragma
like
```nim
{.pragma foo: test.}
```
It will continue to try and process it which leads to the compiler
running into a `FieldDefect`
```
fatal.nim(53)            sysFatal
Error: unhandled exception: field 'sons' is not accessible for type 'TNode' using 'kind = nkIdent' [FieldDefect]
```
This makes it instead bail out trying to process the user pragma if its
invalid
2023-12-07 08:14:23 +01:00
Jacek Sieka
e1a0ff1b8a lexer cleanups (#23037)
* remove some dead code and leftovers from past features
* fix yaml printing of uint64 literals
2023-12-06 18:17:57 +01:00
ringabout
f7bdec6f0d progress 2023-12-06 14:25:34 +00:00
ringabout
88c0ac44fc simple additions 2023-12-06 06:09:25 +00:00
Jake Leahy
44b64e726e Don't recurse into inner functions during asyncjs transform (#23036)
Closes #13341
2023-12-06 04:59:38 +01:00
ringabout
119cfe8bc8 some improvements 2023-12-06 02:27:05 +00:00
ringabout
d20b4d5168 fixes #23019; Regression from 2.0 to devel with raise an unlisted exc… (#23034)
…eption: Exception

fixes #23019

I suppose `implicitPragmas` is called somewhere which converts
`otherPragmas`.
2023-12-05 21:04:41 +01:00
ringabout
ae99903236 wip: intern strings 2023-12-05 14:51:24 +00:00
ringabout
202e21daba forbides adding sons for PType (#23030)
I image `add` for `PType` to be used everythere
2023-12-04 16:20:19 +01:00
Nikolay Nikolov
618ccb6b6a Also show the raises pragma when converting proc types to string (#23026)
This affects also nimsuggest hints (e.g. on mouse hover), as well as
compiler messages.
2023-12-04 07:17:42 +01:00
Jake Leahy
b8fa789393 Fix nimsuggest def being different on proc definition/use (#23025)
Currently the documentation isn't shown when running `def` on the
definition of a proc (Which works for things like variables).
`gcsafe`/`noSideEffects` status also isn't showing up when running `def`
on the definition

Images of current behavior. After PR both look like "Usage"
**Definition**

![image](https://github.com/nim-lang/Nim/assets/19339842/bf75ff0b-9a96-49e5-bf8a-d2c503efa784)
**Usage**

![image](https://github.com/nim-lang/Nim/assets/19339842/15ea3ebf-64e1-48f5-9233-22605183825f)


Issue was the symbol getting passed too early to nimsuggest so it didn't
have all that info, now gets passed once proc is fully semmed
2023-12-04 07:15:16 +01:00
Joachim Hereth
d5780a3e4e strutils.multiReplace: Making order of replacement explicit (#23022)
In the docs for strutils.multiReplace:

Making it more explicit that left to right comes before the order in the
replacements arg (but that the latter matters too).

E.g.

```
echo "ab".multiReplace(@[("a", "1"), ("ax", "2")])
echo "ab".multiReplace(@[("ab", "2"), ("a", "1")])
```

gives

```
1b
2
```

resolves #23016
2023-12-02 22:41:53 +01:00
Jake Leahy
a25843cf80 Show proper error message if trying to run a Nim file in a directory that doesn't exist (#23017)
For example with the command `nim r foo/bar.nim`, if `foo/` doesn't
exist then it shows this message
```
oserrors.nim(92)         raiseOSError
Error: unhandled exception: No such file or directory
Additional info: foo [OSError]
```

After PR it shows
```
Error: cannot open 'foo/bar.nim'
```
Which makes it line up with the error message if `foo/` did exist but
`bar.nim` didn't. Does this by using the same logic for [handling if the
file doesn't
exist](0dc12ec24b/compiler/options.nim (L785-L788))
2023-12-02 05:29:10 +01:00
Andreas Rumpf
0d24f76546 fixes #22552 (#23014) 2023-12-02 05:28:24 +01:00
Erich Reitz
5dfa1345fa related #22534; fixes documentation rendering of custom number literal routine declaration (#23015)
I'm not sure if this is a complete fix, as it does not match the
expected output given in the issue. The expected output given in the
issue highlights the identifier after the `'` the same color as numeric
literals (blue), and this change does not address that. I think that
would involve simplifying `nimNumberPostfix`.

However, this fixes the issue where the routine declaration was rendered
as a string.
New rendering: 
![Screenshot from 2023-11-30
22-17-17](https://github.com/nim-lang/Nim/assets/80008541/b604ce27-a4ad-496b-82c3-0b568d99a8bf)
2023-12-01 07:21:42 +01:00
Andreas Rumpf
ab7faa73ef fixes #22852; real bugfix is tied to bug #22672 (#23013) 2023-11-30 17:59:16 +01:00
ringabout
7ea5aaaebb fixes #23001; give a better warning for PtrToCstringConv (#23005)
fixes #23001
2023-11-30 14:12:12 +01:00
ringabout
bc24340d55 fixes #23006; newSeqUninit -> CT Error; imitate newStringUninit (#23007)
fixes #23006
2023-11-30 14:08:49 +01:00
ringabout
b5f5b74fc8 enable vtable implementation for C++ and make it an experimental feature (#23004)
follow up https://github.com/nim-lang/Nim/pull/22991

- [x] turning it into an experimental feature

---------

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2023-11-30 14:05:45 +01:00
SirOlaf
9140f8e221 Fix endsInNoReturn for case statements (#23009)
While looking at the CI I noticed that there's a couple false positives
for `case` statements that cannot be checked for exhaustiveness since my
changes, this should resolve them.

---------

Co-authored-by: SirOlaf <>
2023-11-30 11:01:42 +01:00
inv2004
0f7ebb490c table.mgetOrPut without default val (#22994)
RFC: https://github.com/nim-lang/RFCs/issues/539

- ~~mgetOrPutDefaultImpl template into `tableimpl.nim` to avoid macros~~
- mgetOrPut for `Table`, `TableRef`, `OrderedTable`, `OrderedTableRef`
- `tests/stdlib/tmget.nim` tests update

---------

Co-authored-by: inv2004 <>
2023-11-30 11:00:33 +01:00
c-blake
beeacc86ff Silence several Hint[Performance] warnings (#23003)
With `--mm:arc` one gets the "implicit copy; if possible, rearrange your
program's control flow" `Performance` warnings without these `move`s.
2023-11-29 22:36:47 +01:00
ringabout
96513b2506 fixes #22926; Different type inferred when setting a default value for an array field (#22999)
fixes #22926
2023-11-29 10:36:20 +01:00
ringabout
795aad4f2a fixes #22996; typeAllowedCheck for default fields (#22998)
fixes #22996
2023-11-29 10:35:50 +01:00
ringabout
30cf33f04d rework the vtable implementation embedding the vtable array directly with new strictions on methods (#22991)
**TODO**
- [x] fixes changelog
With the new option `nimPreviewVtables`, `methods` are confined in the
same module where the type of the first parameter is defined

- [x] make it opt in after CI checks its feasibility

## In the following-up PRs

- [ ] in the following PRs, refactor code into a more efficient one

- [ ] cpp needs special treatments since it cannot embed array in light
of the preceding limits: ref
https://github.com/nim-lang/Nim/pull/20977#discussion_r1035528927; we
can support cpp backends with vtable implementations later on the
comprise that uses indirect vtable access

---------

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2023-11-28 15:11:43 +01:00
Jake Leahy
8cad6ac048 Don't try and get enum value if its invalid (#22997)
Currently running `nimsuggest`/`check` on this code causes the compiler
to raise an exception

```nim
type
  Test = enum
    A = 9.0 
```

```
assertions.nim(34)       raiseAssert
Error: unhandled exception: int128.nim(69, 11) `arg.sdata(3) == 0` out of range [AssertionDefect]
```

Issue was the compiler still trying to get the ordinal value even if it
wasn't an ordinal
2023-11-28 09:38:10 +01:00
Jake Leahy
c31bbb07fb Register declaration of enum field has a use (#22990)
Currently when using `use` with nimsuggest on an enum field, it doesn't
return the definition of the field.

Breaks renaming in IDEs since it will replace all the usages, but not
the declaration
2023-11-27 22:08:05 +01:00
John Viega
5b2fcabff5 fix: std/marshal unmarshaling of ref objects (#22983)
Fixes #16496 

![Marshal doesn't properly unmarshal *most* ref objects; the exceptions
being nil
ones](https://github-production-user-asset-6210df.s3.amazonaws.com/4764481/285471431-a39ee2c5-5670-4b12-aa10-7a10ba6b5b96.gif)
Test case added.

Note that this test (t9754) does pass locally, but there are tons of
failures by default on OS X arm64, mostly around the bohem GC, so it's
pretty spammy, and could easily have missed something. If there are
better instructions please do let me know.

---------

Co-authored-by: John Viega <viega@Johns-MacBook-Pro.local>
Co-authored-by: John Viega <viega@Johns-MBP.localdomain>
Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
2023-11-26 06:32:32 +01:00
tersec
26f2ea149c remove unnecessary side-effects from base64.encode(mime) (#22986)
Fixes https://github.com/nim-lang/Nim/issues/22985
2023-11-25 20:52:42 +01:00
ringabout
379299a5ac fixes #22286; enforce Non-var T destructors by nimPreviewNonVarDestructor (#22975)
fixes #22286
ref https://forum.nim-lang.org/t/10642

For backwards compatibilities, we might need to keep the changes under a
preview compiler flag. Let's see how many packags it break.

**TODO** in the following PRs

- [ ] Turn the `var T` destructors warning into an error with
`nimPreviewNonVarDestructor`

---------

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2023-11-25 18:27:27 +01:00
Nikolay Nikolov
502a4486ae nimsuggest: Added optional command line option '--clientProcessId:XXX' (#22969)
When it is specified, the nimsuggest instance monitors whether this
process is still alive. In case it's found to be dead, nimsuggest shuts
itself down. Currently only implemented on POSIX and Windows platforms.
The switch is silently ignored on other platforms. Note that the Nim
language server should still try to shut down its child nimsuggest
processes. This switch just adds extra protection against crashing Nim
language server and gets rid of the remaining nimsuggest processes,
which consume memory and system resources.
2023-11-24 19:55:53 +01:00
ringabout
816ddd8be7 build nimble with ORC and bump nimble version (#22978)
ref https://github.com/nim-lang/nimble/pull/1074
2023-11-24 15:41:57 +01:00
Andreas Rumpf
ce1a5cb165 progress: 'm' command line switch (#22976) 2023-11-22 09:58:17 +01:00