summary refs log tree commit diff stats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* marking a field with noInit allows to skip constructor initialiser (#22802)Juan M Gómez2023-10-081-0/+30
| | | Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fixes #22787; marks `var section` in the loop as reassign preventing cursor ↵ringabout2023-10-071-0/+37
| | | | | | | | | (#22800) fixes #22787 --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fixes #22778 regression: contentLength implementation type mismatched (#22780)ringabout2023-10-031-0/+1
| | | | fixes #22778 follow up https://github.com/nim-lang/Nim/pull/19835
* fixes #22753; Nimsuggest segfault with invalid assignment to table (#22781)ringabout2023-10-023-7/+47
| | | | | | | | fixes #22753 ## Future work We should turn all the error nodes into nodes of a nkError kind, which could be a industrious task. But perhaps we can add a special treatment for error nodes to make the transition smooth.
* Make `typeRel` behave to spec (#22261)Ryan McConnell2023-09-302-14/+17
| | | | | | | | | | | | | | | | | | | | | | | | The goal of this PR is to make `typeRel` accurate to it's definition for generics: ``` # 3) When used with two type classes, it will check whether the types # matching the first type class (aOrig) are a strict subset of the types matching # the other (f). This allows us to compare the signatures of generic procs in # order to give preferrence to the most specific one: ``` I don't want this PR to break any code, and I want to preserve all of Nims current behaviors. I think that making this more accurate will help serve as ground work for the future. It may not be possible to not break anything but this is my attempt. So that it is understood, this code was part of another PR (#22143) but that problem statement only needed this change by extension. It's more organized to split two problems into two PRs and this issue, being non-breaking, should be a more immediate improvement. --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* case macro now can be used inside generic. Fixes #20435 (#22752)Juan M Gómez2023-09-301-0/+30
| | | | | | | | | fixes #20435 --------- Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> Co-authored-by: Jake Leahy <jake@leahy.dev> Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* C++ Adds support for default arg using object construction syntax. Fixes a ↵Juan M Gómez2023-09-281-2/+29
| | | | | | | | | | compiler crash (#22768) `Foo()` below makes the compiler crash. ```nim proc makeBoo(a:cint = 10, b:cstring = "hello", foo: Foo = Foo()): Boo {.importcpp, constructor.} ```
* fixes #10542; suppresses varargs conversion warnings (#22757)ringabout2023-09-261-0/+24
| | | | fixes #10542 revives and close #20169
* Add test case for #15351 (#22754)Jake Leahy2023-09-261-0/+5
| | | | | Closes #15351 Stumbled across the issue and found it now works
* fixes #22687; js backend - std/bitops/bitsliced throws compile error … ↵ringabout2023-09-211-0/+4
| | | | | | | (#22722) …in typeMasked fixes #22687
* items, pairs and friends now use `unCheckedInc` (#22729)ringabout2023-09-201-0/+4
| | | | | | | | | | | | `{.push overflowChecks: off.}` works in backends. Though it could be implemented as a magic function. By inspecting the generated C code, the overflow check is eliminated in the debug or release mode. ![image](https://github.com/nim-lang/Nim/assets/43030857/49c3dbf4-675e-414a-b972-b91cf218c9f8) Likewise, the index checking is probably not needed.
* fixes compiler crash by preventing exportc on generics (#22731)Juan M Gómez2023-09-201-0/+8
| | | Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* `constructor` now uses `result` instead of `this` (#22724)Juan M Gómez2023-09-191-4/+4
|
* second test case haul for templates and generics (#22728)metagn2023-09-196-6/+62
| | | | closes #8390, closes #11726, closes #8446, closes #21221, closes #7461, closes #7995
* make parseEnum skip type aliases for enum type sym (#22727)metagn2023-09-191-4/+15
| | | fixes #22726
* fixes `result` requires explicit initialization on noReturn code (#22717)ringabout2023-09-181-0/+27
| | | | | | fixes #21615; fixes #16735 It also partially fixes | #22673, though It still gives 'baseless' warnings.
* prevents declaring a constructor without importcpp fixes #22712 (#22715)Juan M Gómez2023-09-181-0/+15
| | | Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* make expressions opt in to symchoices (#22716)metagn2023-09-184-3/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | refs #22605 Sym choice nodes are now only allowed to pass through semchecking if contexts ask for them to (with `efAllowSymChoice`). Otherwise they are resolved or treated as ambiguous. The contexts that can receive symchoices in this PR are: * Call operands and addresses and emulations of such, which will subject them to overload resolution which will resolve them or fail. * Type conversion operands only for routine symchoices for type disambiguation syntax (like `(proc (x: int): int)(foo)`), which will resolve them or fail. * Proc parameter default values both at the declaration and during generic instantiation, which undergo type narrowing and so will resolve them or fail. This means unless these contexts mess up sym choice nodes should never leave the semchecking stage. This serves as a blueprint for future improvements to intermediate symbol resolution. Some tangential changes are also in this PR: 1. The `AmbiguousEnum` hint is removed, it was always disabled by default and since #22606 it only started getting emitted after the symchoice was soundly resolved. 2. Proc setter syntax (`a.b = c` becoming `` `b=`(a, c) ``) used to fully type check the RHS before passing the transformed call node to proc overloading. Now it just passes the original node directly so proc overloading can deal with its typechecking.
* Fix #22713: Make size unknown for tyForward (#22714)SirOlaf2023-09-171-0/+12
| | | | | | | Close #22713 --------- Co-authored-by: SirOlaf <>