summary refs log tree commit diff stats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* fixes a typo in the test (#23140)ringabout2023-12-291-1/+1
|
* retain postfix node in type section typed AST, with docgen fix (#23101)metagn2023-12-232-1/+8
| | | | | | Continued from #23096 which was reverted due to breaking a package and failing docgen tests. Docgen should now work, but ~~a PR is still pending for the package: https://github.com/SciNim/Unchained/pull/45~~ has been merged
* add switch, warning, and `bind` support for new generic injection behavior ↵metagn2023-12-222-0/+79
| | | | | | | | | | | | | | | | | | | | | (#23102) refs #23091, especially post merge comments Unsure if `experimental` and `bind` are the perfect constructs to use but they seem to get the job done here. Symbol nodes do not get marked `nfOpenSym` if the `bind` statement is used for their symbol, and `nfOpenSym` nodes do not get replaced by new local symbols if the experimental switch is not enabled in the local context (meaning it also works with `push experimental`). However this incurs a warning as the fact that the node is marked `nfOpenSym` means we did not `bind` it, so we might want to do that or turn on the experimental switch if we didn't intend to bind it. The experimental switch name is arbitrary and could be changed. --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Don't crash for invalid toplevel parseStmt/Expr calls (#23089)Jake Leahy2023-12-191-0/+15
| | | | | | | | | | | | | | | This code will crash `check`/`nimsuggest` since the `ra` register is uninitialised ```nim import macros static: discard parseExpr("'") ``` Now it assigns an empty node so that it has something Testament changes were so I could properly write a test. It would pass even with a segfault since it could find the error
* Revert "retain postfix node in type section typed AST" (#23098)metagn2023-12-192-8/+1
| | | Reverts nim-lang/Nim#23096
* retain postfix node in type section typed AST (#23096)metagn2023-12-182-1/+8
| | | fixes #22933
* allow replacing captured syms in macro calls in generics (#23091)metagn2023-12-181-0/+86
| | | | | | | | | | | | | | | | | | fixes #22605, separated from #22744 This marks symbol captures in macro calls in generic contexts as `nfOpenSym`, which means if there is a new symbol in the local instantiatied body during instantiation time, this symbol replaces the captured symbol. We have to be careful not to consider symbols outside of the instantiation body during instantiation, because this will leak symbols from the instantiation context scope rather than the original declaration scope. This is done by checking if the local context owner (maybe should be the symbol of the proc currently getting instantiated instead? not sure how to get this) is the same as or a parent owner of the owner of the replacement candidate symbol. This solution is distinct from the symchoice mechanisms which we originally assumed had to be related, if this assumption was wrong it would explain why this solution took so long to arrive at.
* Mark `macros.error` as `.noreturn.` (#23081)Jake Leahy2023-12-172-0/+18
| | | | | | | | | | | | | | | Closes #14329 Marks `macros.error` as `.noreturn` so that it can be used in expressions. This also fixes the issue that occurred in #19659 where a stmt that could be an expression (Due to having `discardable` procs at the end of other branches) would believe a `noreturn` proc is returning the same type e.g. ```nim proc bar(): int {.discardable.} = discard if true: bar() else: quit(0) # Says that quit is of type `int` and needs to be used/discarded except it actually has no return type ```
* Allow `parseAll` to parse statements separated by semicolons (#23088)Jake Leahy2023-12-171-0/+4
| | | | | | | | | | | | | | | | | | Fixes the second issue listed in #9918. Fixed by replacing the logic used in `parseAll` with just a continious loop to `complexOrSimpleStmt` like what the [normal parser does](https://github.com/nim-lang/Nim/blob/devel/compiler/passes.nim#L143-L146). `complexOrSimpleStmt` [guarantees progress](https://github.com/nim-lang/Nim/blob/devel/compiler/parser.nim#L2541) so we don't need to check progress ourselves. Also allows `nimpretty` to parse more valid Nim code such as ```nim proc foo(); # Would complain about indention here # ... proc foo() = # ... ```
* rationals: support Rational[SomeUnsignedInt] (#23046)shirleyquirk2023-12-151-0/+9
| | | | | | | | fixes #22227 rationale: - `3u - 4u` is supported why not`3u.toRational - 4u.toRational` - all of rationals' api is on SomeInteger, looks like unsigned is declared as supported - math on unsigned rationals is meaningful and useful.
* Param match relax (#23033)Ryan McConnell2023-12-155-2/+59
| | | | | | | | | | | #23032 --------- Co-authored-by: Nikolay Nikolov <nickysn@gmail.com> Co-authored-by: Pylgos <43234674+Pylgos@users.noreply.github.com> Co-authored-by: Andreas Rumpf <rumpf_a@web.de> Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> Co-authored-by: Jason Beetham <beefers331@gmail.com>
* Overloads passed to static proc parameters now convert to the desired… ↵Jason Beetham2023-12-141-1/+8
| | | | | (#23063) … type mirroring proc params
* type graph refactor; part 3 (#23064)Andreas Rumpf2023-12-141-16/+0
|
* fixes #9381; Fix double evaluation of types in generic objects (#23072)Pylgos2023-12-141-0/+14
| | | fixes https://github.com/nim-lang/Nim/issues/9381
* fixes #23060; `editDistance` wrongly compare the length of rune strings (#23062)ringabout2023-12-131-0/+5
| | | fixes #23060
* Look up generic parameters when found inside semOverloadedCall, fixin… ↵Jason Beetham2023-12-121-0/+9
| | | | | | | | | (#23054) …g static procs --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Don't process a user pragma if its invalid (#23041)Jake Leahy2023-12-071-0/+9
| | | | | | | | | | | | | | | 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
* Don't recurse into inner functions during asyncjs transform (#23036)Jake Leahy2023-12-061-0/+5
| | | Closes #13341
* fixes #23019; Regression from 2.0 to devel with raise an unlisted exc… ↵ringabout2023-12-051-0/+22
| | | | | | | | | | (#23034) …eption: Exception fixes #23019 I suppose `implicitPragmas` is called somewhere which converts `otherPragmas`.
* Also show the `raises` pragma when converting proc types to string (#23026)Nikolay Nikolov2023-12-041-1/+1
| | | | This affects also nimsuggest hints (e.g. on mouse hover), as well as compiler messages.
* fixes #22552 (#23014)Andreas Rumpf2023-12-021-0/+56
|
* enable vtable implementation for C++ and make it an experimental feature ↵ringabout2023-11-305-5/+9
| | | | | | | | | | | (#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-301-4/+41
| | | | | | | | | 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-301-0/+16
| | | | | | | | | | | 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 <>
* fixes #22926; Different type inferred when setting a default value for an ↵ringabout2023-11-292-6/+30
| | | | | array field (#22999) fixes #22926
* fixes #22996; `typeAllowedCheck` for default fields (#22998)ringabout2023-11-291-0/+7
| | | fixes #22996
* rework the vtable implementation embedding the vtable array directly with ↵ringabout2023-11-289-145/+197
| | | | | | | | | | | | | | | | | | | | | | | | 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-281-0/+8
| | | | | | | | | | | | | | | | | | 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
* fix: std/marshal unmarshaling of ref objects (#22983)John Viega2023-11-261-1/+41
| | | | | | | | | | | | | | | | | | | 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-251-0/+4
| | | Fixes https://github.com/nim-lang/Nim/issues/22985
* fixes #22286; enforce Non-var T destructors by `nimPreviewNonVarDestructor` ↵ringabout2023-11-259-29/+63
| | | | | | | | | | | | | | | | | | (#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>
* fixes #22971; `inferGenericTypes` does not work with method call syntax (#22972)Pylgos2023-11-221-1/+23
| | | fixes #22971
* closes #12464; adds a test case (#22967)ringabout2023-11-201-0/+13
| | | closes #12464
* fixes #22939; fixes #16890; push should but doesn't apply to importc … ↵ringabout2023-11-192-16/+20
| | | | | | | | | | | | | | | | | | | | | | (#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-191-0/+39
| | | | | | | | | | | (#22941) …tes invalid C identifiers fixes #22913 fixes #12985 differently `{.push.} now does not apply to generic instantiations`
* fixes #22947; static integers in quote do [backport] (#22948)ringabout2023-11-181-0/+13
| | | fixes #22947
* Fix OSError `errorCode` field is not assigned a value (#22954)握猫猫2023-11-171-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | 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") ```
* fixes #22932; treats closure iterators as pointers (#22934)ringabout2023-11-141-1/+7
| | | | | | | | fixes #22932 follow up https://github.com/nim-lang/Nim/pull/21629 --------- Co-authored-by: Nickolay Bukreyev <SirNickolas@users.noreply.github.com>
* fixes #22673; Cannot prove that result is initialized for a placehold… ↵ringabout2023-11-061-0/+21
| | | | | | | | (#22915) …er base method returning a lent fixes #22673
* fixes #22902; borrow from proc return type mismatch (#22908)ringabout2023-11-041-0/+8
| | | fixes #22902
* fixes #22866; fixes #19998; ensure destruction for Object construction with ↵ringabout2023-11-022-10/+16
| | | | | | custom destructors (#22901) fixes #22866; fixes #19998
* minor fixes for node20 (#22894)ringabout2023-10-311-1/+1
|
* C++: ptr fields now pulls the whole type if it's a member in nkDotExpr (#22855)Juan M Gómez2023-10-232-1/+18
|
* Fix #22826: Don't skip generic instances in type comparison (#22828)SirOlaf2023-10-211-0/+8
| | | | | | | | | | | | | | Close #22826 I am not sure why this code skips generic insts, so letting CI tell me. Update: It has told me nothing. Maybe someone knows during review. Issue itself seems to be that the generic instance is skipped thus it ends up being just `float` which makes it use the wrong generic instance of the proc because it matches the one in cache --------- Co-authored-by: SirOlaf <>
* fixes #22844; uses arrays to store holeyenums for iterations; much more ↵ringabout2023-10-201-0/+16
| | | | | efficient than sets and reasonable for holeyenums (#22845) fixes #22844
* closes #16919; followup #16820, test tsugar on all backends (#22829)ringabout2023-10-161-8/+8
| | | | closes #16919 followup #16820
* fixes #19250; fixes #22259; ORC AssertionDefect not ↵ringabout2023-10-131-0/+53
| | | | | | | | | | | containsManagedMemory(n.typ) (#22823) fixes #19250 fixes #22259 The strings, seqs, refs types all have this flag, why should closures be treated differently? follow up https://github.com/nim-lang/Nim/pull/14336
* fixes #22354; Wrong C++ codegen for default parameter values in ORC (#22819)ringabout2023-10-131-28/+47
| | | | | | fixes #22354 It skips `nkHiddenAddr`. No need to hoist `var parameters` without side effects. Besides, it saves lots of temporary variables in ORC.
* fixes #22790; use cast suppress AnyEnumConv warnings for enums withou… ↵ringabout2023-10-111-0/+1
| | | | | | | (#22813) …t holes fixes #22790
* adds support for noDecl in constructor (#22811)Juan M Gómez2023-10-111-1/+10
| | | Notice the test wouldnt link before