summary refs log tree commit diff stats
Commit message (Collapse)AuthorAgeFilesLines
* Look up generic parameters when found inside semOverloadedCall, fixin… ↵Jason Beetham2023-12-122-0/+22
| | | | | | | | | (#23054) …g static procs --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Ast stmt now saves its ast structure in the compiler (#23053)ASVIEST2023-12-122-1/+8
| | | | | | | see https://github.com/nim-lang/Nim/issues/23052 --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Only suggest symbols that could be pragmas when typing a pragma (#23040)Jake Leahy2023-12-075-3/+85
| | | | | | 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
* Don't process a user pragma if its invalid (#23041)Jake Leahy2023-12-072-1/+13
| | | | | | | | | | | | | | | 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
* lexer cleanups (#23037)Jacek Sieka2023-12-067-76/+20
| | | | * remove some dead code and leftovers from past features * fix yaml printing of uint64 literals
* Don't recurse into inner functions during asyncjs transform (#23036)Jake Leahy2023-12-062-0/+7
| | | Closes #13341
* fixes #23019; Regression from 2.0 to devel with raise an unlisted exc… ↵ringabout2023-12-052-1/+23
| | | | | | | | | | (#23034) …eption: Exception fixes #23019 I suppose `implicitPragmas` is called somewhere which converts `otherPragmas`.
* forbides adding sons for `PType` (#23030)ringabout2023-12-044-16/+7
| | | I image `add` for `PType` to be used everythere
* Also show the `raises` pragma when converting proc types to string (#23026)Nikolay Nikolov2023-12-042-2/+10
| | | | This affects also nimsuggest hints (e.g. on mouse hover), as well as compiler messages.
* Fix nimsuggest `def` being different on proc definition/use (#23025)Jake Leahy2023-12-043-6/+26
| | | | | | | | | | | | | | | | | | 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
* strutils.multiReplace: Making order of replacement explicit (#23022)Joachim Hereth2023-12-021-2/+3
| | | | | | | | | | | | | | | | | | | | | | 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
* Show proper error message if trying to run a Nim file in a directory that ↵Jake Leahy2023-12-021-1/+4
| | | | | | | | | | | | | | | | | | | | 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](https://github.com/ire4ever1190/Nim/blob/0dc12ec24b7902ef0023a9e694faa11bcf99e257/compiler/options.nim#L785-L788)
* fixes #22552 (#23014)Andreas Rumpf2023-12-026-10/+84
|
* related #22534; fixes documentation rendering of custom number literal ↵Erich Reitz2023-12-011-11/+12
| | | | | | | | | | | | | | | 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)
* fixes #22852; real bugfix is tied to bug #22672 (#23013)Andreas Rumpf2023-11-301-1/+4
|
* fixes #23001; give a better warning for PtrToCstringConv (#23005)ringabout2023-11-301-1/+1
| | | fixes #23001
* fixes #23006; newSeqUninit -> CT Error; imitate `newStringUninit` (#23007)ringabout2023-11-301-1/+4
| | | fixes #23006
* enable vtable implementation for C++ and make it an experimental feature ↵ringabout2023-11-3015-24/+42
| | | | | | | | | | | (#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>
* Fix endsInNoReturn for case statements (#23009)SirOlaf2023-11-303-14/+64
| | | | | | | | | 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 <>
* table.`mgetOrPut` without default val (#22994)inv20042023-11-303-4/+81
| | | | | | | | | | | 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 <>
* Silence several Hint[Performance] warnings (#23003)c-blake2023-11-294-6/+5
| | | | With `--mm:arc` one gets the "implicit copy; if possible, rearrange your program's control flow" `Performance` warnings without these `move`s.
* fixes #22926; Different type inferred when setting a default value for an ↵ringabout2023-11-293-6/+36
| | | | | array field (#22999) fixes #22926
* fixes #22996; `typeAllowedCheck` for default fields (#22998)ringabout2023-11-293-2/+15
| | | fixes #22996
* rework the vtable implementation embedding the vtable array directly with ↵ringabout2023-11-2828-197/+555
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* Don't try and get enum value if its invalid (#22997)Jake Leahy2023-11-282-3/+12
| | | | | | | | | | | | | | | | | | 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
* Register declaration of enum field has a use (#22990)Jake Leahy2023-11-272-0/+16
| | | | | | | 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
* fix: std/marshal unmarshaling of ref objects (#22983)John Viega2023-11-262-2/+43
| | | | | | | | | | | | | | | | | | | 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>
* remove unnecessary side-effects from base64.encode(mime) (#22986)tersec2023-11-252-12/+8
| | | Fixes https://github.com/nim-lang/Nim/issues/22985
* fixes #22286; enforce Non-var T destructors by `nimPreviewNonVarDestructor` ↵ringabout2023-11-2513-41/+84
| | | | | | | | | | | | | | | | | | (#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>
* nimsuggest: Added optional command line option '--clientProcessId:XXX' (#22969)Nikolay Nikolov2023-11-243-0/+42
| | | | | | | | | | 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.
* build nimble with ORC and bump nimble version (#22978)ringabout2023-11-241-2/+2
| | | ref https://github.com/nim-lang/nimble/pull/1074
* progress: 'm' command line switch (#22976)Andreas Rumpf2023-11-223-2/+9
|
* fixes #22971; `inferGenericTypes` does not work with method call syntax (#22972)Pylgos2023-11-222-3/+25
| | | fixes #22971
* closes #12464; adds a test case (#22967)ringabout2023-11-201-0/+13
| | | closes #12464
* Don't provide suggestions for enum fields (#22959)Jake Leahy2023-11-202-0/+20
| | | | | | | | | Currently the suggestions create a lot of noise when creating enum fields. I don't see any way of a macro creating fields (when called inside an enum) so it should be safe to not show suggestions --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* IC: progress and refactorings (#22961)Andreas Rumpf2023-11-2045-360/+456
|
* fixes #22939; fixes #16890; push should but doesn't apply to importc … ↵ringabout2023-11-193-16/+26
| | | | | | | | | | | | | | | | | | | | | | (#22944) …var/let symbols fixes #22939 fixes #16890 Besides, it was applied to let/const/var with pragmas, now it is universally applied. ```nim {.push exportc.} proc foo = let bar = 12 echo bar {.pop.} ``` For example, the `bar` variable will be affected by `exportc`.
* fixes #22913; fixes #12985 differently push-ing pragma exportc genera… ↵ringabout2023-11-193-1/+46
| | | | | | | | | | | (#22941) …tes invalid C identifiers fixes #22913 fixes #12985 differently `{.push.} now does not apply to generic instantiations`
* enable nimwc testing (#22960)ringabout2023-11-191-1/+1
| | | ref https://github.com/ThomasTJdev/nim_websitecreator/pull/145
* Introduced version 4 of the NimSuggest protocol. The InlayHints feature made ↵Nikolay Nikolov2023-11-181-2/+8
| | | | | | | | | | V4 or later only. (#22953) Since nimsuggest now has a protocol version support detection via `--info:protocolVer`, the InlayHints feature can be moved to protocol V4. This way, the Nim language server can detect the nimsuggest version and avoid sending unsupported `InlayHints` commands to older nimsuggest versions. Related nim language server PR: https://github.com/nim-lang/langserver/pull/60
* let `InotifyEvent` type `sizeof`-able (#22958)Derek2023-11-181-1/+2
| | | | Since the `InotifyEvent`s are receive through `read()`, user need the size of the type.
* fixes #22947; static integers in quote do [backport] (#22948)ringabout2023-11-182-1/+14
| | | fixes #22947
* Fix OSError `errorCode` field is not assigned a value (#22954)握猫猫2023-11-176-54/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | In this PR, the following changes were made: 1. Replaced `raise newException(OSError, osErrorMsg(errno))` in batches with `raiseOSError(errcode)`. 2. Replaced `newException(OSError, osErrorMsg(errno))` in batches with `newOSError(errcode)`. There are still some places that have not been replaced. After checking, they are not system errors in the traditional sense. ```nim proc dlclose(lib: LibHandle) = raise newException(OSError, "dlclose not implemented on Nintendo Switch!") ``` ```nim if not fileExists(result) and not dirExists(result): # consider using: `raiseOSError(osLastError(), result)` raise newException(OSError, "file '" & result & "' does not exist") ``` ```nim proc paramStr*(i: int): string = raise newException(OSError, "paramStr is not implemented on Genode") ```
* 'j' format specifier docs (#22928)Angel Ezquerra2023-11-172-5/+11
| | | | | | | | | | | | This is a small improvement on top of PR #22924, which documents the new 'j' format specifier for Complex numbers. In addition to that it moves the handling of the j specifier into the function that actually implements it (formatValueAsComplexNumber), which seems a little cleaner. --------- Co-authored-by: Angel Ezquerra <angel_ezquerra@keysight.com> Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
* Minor documentation change (#22951)Marko Schütz-Schmuck2023-11-171-3/+2
| | | I've made a small change in the explanation of `void` types.
* doc: update manual_experimental.md (#22949)Ikko Eltociear Ashimine2023-11-161-1/+1
| | | sematics -> semantics
* nimsuggest: Instead of checking for protocol version 3 exactly, check for ↵Nikolay Nikolov2023-11-152-5/+5
| | | | | | | | | version 3 or later. (#22945) Refactored the way nimsuggest checks for protocol version 3. Instead of checking for version 3 exactly, it now checks for version 3 or later. This way, once a version 4 is introduced, it will use version 3 as a base line, and then extra changes to the protocol can be added on top. No functional changes are introduced in this commit.
* Added new command line option `--info:X` to nimsuggest for obtaining ↵Nikolay Nikolov2023-11-151-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | information. (#22940) `--info:protocolVer` returns the highest nimsuggest protocol version that is supported (currently, it's version 3). `--info:nimVer` returns the Nim compiler version that nimsuggest uses internally. Note that you can obtain the Nim compiler version via `nimsuggest -v`, but that requires parsing the output, which looks like this: ``` Nim Compiler Version 2.1.1 [Linux: amd64] Compiled at 2023-11-14 Copyright (c) 2006-2023 by Andreas Rumpf git hash: 47ddfeca5247dce992becd734d1ae44e621207b8 active boot switches: -d:release -d:danger --gc:markAndSweep ``` `--info:nimVer` will return just: ``` 2.1.1 ```
* minor fixes for changelog (#22938)ringabout2023-11-141-1/+1
| | | | ref https://github.com/nim-lang/Nim/commit/1bb117cd7a49954832d21e6a1502492770acb77b#r132468022
* fixes #22932; treats closure iterators as pointers (#22934)ringabout2023-11-142-3/+9
| | | | | | | | fixes #22932 follow up https://github.com/nim-lang/Nim/pull/21629 --------- Co-authored-by: Nickolay Bukreyev <SirNickolas@users.noreply.github.com>