summary refs log tree commit diff stats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* implements RFC: [C++] Constructors as default initializers (#22694)Juan M Gómez2023-09-141-0/+33
| | | Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* produce better code for object constructions and 'result' [backport] (#22668)Andreas Rumpf2023-09-111-4/+7
|
* fixes #22680 Nim zero clear an object inherits C++ imported class when a ↵Juan M Gómez2023-09-111-0/+50
| | | | proc return it (#22684)
* fixes #22669 constructor pragma doesnt init Nim default fields (#22670)Juan M Gómez2023-09-101-1/+34
| | | | | | | fixes #22669 constructor pragma doesnt init Nim default fields --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fixes #22679 Nim zero clear an object contains C++ imported class when a ↵Juan M Gómez2023-09-101-0/+50
| | | | proc return it (#22681)
* Instantiates generics in the module that uses it (#22513)Juan M Gómez2023-09-091-0/+11
| | | | | | | | | | Attempts to move the generic instantiation to the module that uses it. This should decrease re-compilation times as the source module where the generic lives doesnt need to be recompiled --------- Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fixes #22664; guard against potential seqs self assignments (#22671)ringabout2023-09-081-0/+21
| | | fixes #22664
* fixes #22662 Procs with constructor pragma doesn't initialize object's ↵Juan M Gómez2023-09-081-1/+22
| | | | | | | | | | fields (#22665) fixes #22662 Procs with constructor pragma doesn't initialize object's fields --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Fix #21742: Check generic alias depth before skip (#22443)SirOlaf2023-09-081-0/+10
| | | | | | | | | | | | | | | Close #21742 Checking if there's any side-effects and if just changing typeRel is adequate for this issue before trying to look into related ones. `skipBoth` is also not that great, it can lead to code that works sometimes but fails when the proc is instantiated with branching aliases. This is mostly an issue with error clarity though. --------- Co-authored-by: SirOlaf <unknown> Co-authored-by: SirOlaf <>
* Fix #17509: Continue instead of return with unfinished generics (#22563)SirOlaf2023-09-071-0/+25
| | | | | | | | | | | | | | | | | | | Close #17509 Current knowledge: - delaying cache fixes the issue - changing return of `if inst.len < key.len:` in `searchInstTypes` to `continue` fixes the issue. With return the broken types are also cached over and over Related issues are completely unaffected as of now, so there must be something deeper. I am also still trying to find the true cause, so feel free to ignore for now --------- Co-authored-by: SirOlaf <>
* make getType nodes of generic insts have full inst type (#22655)metagn2023-09-071-0/+35
| | | | | | | | | | | | | fixes #22639 for the third time Nodes generated by `getType` for `tyGenericInst` types, instead of having the original `tyGenericInst` type, will have the type of the last child (due to the `mapTypeToAst` calls which set the type to the given argument). This will cause subsequent `getType` calls to lose information and think it's OK to use the sym of the instantiated type rather than fully expand the generic instantiation. To prevent this, update the type of the node from the `mapTypeToAst` calls to the full generic instantiation type.
* fully revert generic inst sym change, test #22646 (#22653)metagn2023-09-062-35/+32
| | | | | | | reverts #22642, reopens #22639, closes #22646, refs #22650, refs https://github.com/alaviss/union/issues/51, refs #22652 The fallout is too much from #22642, we can come back to it if we can account for all the affected code.
* fixes #22619; don't lift cursor fields in the hook calls (#22638)ringabout2023-09-051-0/+79
| | | | | | | | | | | | | | | | | | | | | | | fixes https://github.com/nim-lang/Nim/issues/22619 It causes double free for closure iterators because cursor fields are destroyed in the lifted destructors of `Env`. Besides, according to the Nim manual > In fact, cursor more generally prevents object construction/destruction pairs and so can also be useful in other contexts. At least, destruction of cursor fields might cause troubles. todo - [x] tests - [x] revert a certain old PR --------- Co-authored-by: zerbina <100542850+zerbina@users.noreply.github.com>
* fix sym of created generic instantiation type (#22642)metagn2023-09-051-4/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fixes #22639 A `tyGenericInst` has its last son as the instantiated body of the original generic type. However this type keeps its original `sym` field from the original generic types, which means the sym's type is uninstantiated. This causes problems in the implementation of `getType`, where it uses the `sym` fields of types to represent them in AST, the relevant example for the issue being [here](https://github.com/nim-lang/Nim/blob/d13aab50cf465a7f2edf9c37a4fa30e128892e72/compiler/vmdeps.nim#L191) called from [here](https://github.com/nim-lang/Nim/blob/d13aab50cf465a7f2edf9c37a4fa30e128892e72/compiler/vmdeps.nim#L143). To fix this, create a new symbol from the original symbol for the instantiated body during the creation of `tyGenericInst`s with the appropriate type. Normally `replaceTypeVarsS` would be used for this, but here it seems to cause some recursion issue (immediately gives an error like "cannot instantiate HSlice[T, U]"), so we directly set the symbol's type to the instantiated type. Avoiding recursion means we also cannot use `replaceTypeVarsN` for the symbol AST, and the symbol not having any AST crashes the implementation of `getType` again [here](https://github.com/nim-lang/Nim/blob/d13aab50cf465a7f2edf9c37a4fa30e128892e72/compiler/vmdeps.nim#L167), so the symbol AST is set to the original generic type AST for now which is what it was before anyway. Not sure about this because not sure why the recursion issue is happening, putting it at the end of the proc doesn't help either. Also not sure if the `cl.owner != nil and s.owner != cl.owner` condition from `replaceTypeVarsS` is relevant here. This might also break some code if it depended on the original generic type symbol being given.
* fixes branches interacting with break, raise etc. in strictdefs (#22627)ringabout2023-09-042-0/+157
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ```nim {.experimental: "strictdefs".} type Test = object id: int proc test(): Test = if true: return Test() else: return echo test() ``` I will tackle https://github.com/nim-lang/Nim/issues/16735 and #21615 in the following PR. The old code just premises that in branches ended with returns, raise statements etc. , all variables including the result variable are initialized for that branch. It's true for noreturn statements. But it is false for the result variable in a branch tailing with a return statement, in which the result variable is not initialized. The solution is not perfect for usages below branch statements with the result variable uninitialized, but it should suffice for now, which gives a proper warning. It also fixes ```nim {.experimental: "strictdefs".} type Test = object id: int proc foo {.noreturn.} = discard proc test9(x: bool): Test = if x: foo() else: foo() ``` which gives a warning, but shouldn't
* docgen: add Pandoc footnotes (fixes #21080) (#22591)Andrey Makarov2023-09-032-3/+70
| | | | | | | | | | This implements Pandoc Markdown-style footnotes, that are compatible with Pandoc referencing syntax: Ref. [^ftn]. [^ftn]: Block. See https://pandoc.org/MANUAL.html#footnotes for more examples.
* resolve unambiguous enum symchoices from local scope, error on rest (#22606)metagn2023-09-033-13/+28
| | | | | | | | | | | | | | | | fixes #22598, properly fixes #21887 and fixes test case issue number When an enum field sym choice has to choose a type, check if its name is ambiguous in the local scope, then check if the first symbol found in the local scope is the first symbol in the sym choice. If so, choose that symbol. Otherwise, give an ambiguous identifier error. The dependence on the local scope implies this will always give ambiguity errors for unpicked enum symchoices from generics and templates and macros from other scopes. We can change `not isAmbiguous(...) and foundSym == first` to `not (isAmbiguous(...) and foundSym == first)` to make it so they never give ambiguity errors, and always pick the first symbol in the symchoice. I can do this if this is preferred, but no code from CI seems affected.
* Exclude block from endsInNoReturn, fix regression (#22632)SirOlaf2023-09-021-13/+0
| | | Co-authored-by: SirOlaf <>
* fix isNil folding for compile time closures (#22574)metagn2023-09-021-0/+8
| | | fixes #20543
* use dummy dest for void branches to fix noreturn in VM (#22617)metagn2023-09-011-0/+32
| | | fixes #22216
* unify explicit generic param semchecking in calls (#22618)metagn2023-09-011-1/+20
| | | fixes #9040
* fixes internal error: no generic body fixes #1500 (#22580)Juan M Gómez2023-09-011-0/+8
| | | | | | | | | | | * fixes internal error: no generic body fixes #1500 * adds guard * adds guard * removes unnecessary test * refactor: extracts containsGenericInvocationWithForward
* resolve local symbols in generic type call RHS (#22610)metagn2023-09-012-0/+20
| | | | | resolve local symbols in generic type call fixes #14509
* don't update const symbol on const section re-sems (#22609)metagn2023-09-011-0/+10
| | | fixes #19849
* fixes #22613; Default value does not work with object's discriminator (#22614)ringabout2023-09-011-1/+16
| | | | | | | | | | | | | | | * fixes #22613; Default value does not work with object's discriminator fixes #22613 * merge branches * add a test case * fixes status * remove outdated comments * move collectBranchFields into the global scope
* Fix #22604: Make endsInNoReturn traverse the tree (#22612)SirOlaf2023-09-012-2/+61
| | | | | | | | | | | | | | | | | * Rewrite endsInNoReturn * Handle `try` stmt again and add tests * Fix unreachable code warning * Remove unreachable code in semexprs again * Check `it.len` before skip * Move import of assertions --------- Co-authored-by: SirOlaf <>
* type annotations for variable tuple unpacking, better error messages (#22611)metagn2023-09-012-1/+18
| | | | | | | | | * type annotations for variable tuple unpacking, better error messages closes #17989, closes https://github.com/nim-lang/RFCs/issues/339 * update grammar * fix test
* closes #22600; adds a test case (#22602)ringabout2023-08-311-0/+25
| | | closes #22600
* fixes #17197; fixes #22560; fixes the dest of newSeqOfCap in refc (#22594)ringabout2023-08-311-0/+17
|
* handle typedesc params in VM (#22581)metagn2023-08-302-2/+21
| | | | | | | | | * handle typedesc params in VM fixes #15760 * add test * fix getType(typedesc) test
* clearer error for different size int/float cast in VM (#22582)metagn2023-08-291-0/+3
| | | refs #16547
* fixes #22555; implements `newStringUninit` (#22572)ringabout2023-08-291-0/+11
| | | | | | | | | | | | | * fixes newStringUninitialized; implement `newStringUninitialized` * add a simple test case * adds a changelog * Update lib/system.nim * Apply suggestions from code review rename to newStringUninit
* correct logic for qualified symbol in templates (#22577)metagn2023-08-281-0/+4
| | | | | | | * correct logic for qualified symbol in templates fixes #19865 * add test
* add test case for #19095 (#22566)Bung2023-08-281-0/+35
|
* close #9334 (#22565)Bung2023-08-271-0/+19
|
* fix #22548;environment misses for type reference in iterator access n… ↵Bung2023-08-272-0/+43
| | | | | | | | | | | | | (#22559) * fix #22548;environment misses for type reference in iterator access nested in closure * fix #21737 * Update lambdalifting.nim * remove containsCallKinds * simplify
* test case haul for old generic/template/macro issues (#22564)metagn2023-08-279-34/+248
| | | | | | | | | | | | * test case haul for old generic/template/macro issues closes #12582, closes #19552, closes #2465, closes #4596, closes #15246, closes #12683, closes #7889, closes #4547, closes #12415, closes #2002, closes #1771, closes #5121 The test for #5648 is also moved into its own test from `types/tissues_types` due to not being joinable. * fix template gensym test
* fix generic param substitution in templates (#22535)metagn2023-08-251-0/+80
| | | | | | | * fix generic param substitution in templates fixes #13527, fixes #17240, fixes #6340, fixes #20033, fixes #19576, fixes #19076 * fix bare except in test, test updated packages in CI
* round out tuple unpacking assignment, support underscores (#22537)metagn2023-08-244-6/+18
| | | | | | | | | | | | | | | * round out tuple unpacking assignment, support underscores fixes #18710 * fix test messages * use discard instead of continue Co-authored-by: Andreas Rumpf <rumpf_a@web.de> --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* make jsffi properly gensym (#22539)metagn2023-08-231-0/+6
| | | fixes #21208
* Fix #21532: Check if template return is untyped (#22517)SirOlaf2023-08-231-0/+8
| | | | | | | | | * Don't ignore return in semTemplateDef * Add test --------- Co-authored-by: SirOlaf <>
* allow non-pragma special words as user pragmas (#22526)metagn2023-08-211-0/+5
| | | | | allow non-pragma special words as macro pragmas fixes #22525
* fix getNullValue for cstring in VM, make other VM code aware of nil cstring ↵metagn2023-08-211-0/+31
| | | | | | | | | | | | | (#22527) * fix getNullValue for cstring in VM fixes #22524 * very ugly fixes, but fix #15730 * nil cstring len works, more test lines * fix high
* use old typeinfo generation for hot code reloading (#22518)metagn2023-08-201-0/+1
| | | | | * use old typeinfo generation for hot code reloading * at least test hello world compilation on orc
* replace getOpt with getopt (#22515)Nan Xiao2023-08-196-6/+6
|
* Add staticFileExists and staticDirExists (#22278)Tomohiro2023-08-182-0/+10
|
* make float32 literals stringifying behave in JS the same as in C (#22500)ringabout2023-08-171-3/+2
|
* cascade tyFromExpr in type conversions in generic bodies (#22499)metagn2023-08-171-0/+8
| | | fixes #22490, fixes #22491, adapts #22029 to type conversions
* close #22748; cursorinference + -d:nimNoLentIterators results in err… (#22495)ringabout2023-08-171-0/+46
| | | closed #22748; cursorinference + -d:nimNoLentIterators results in erroneous recursion
* When in object handles procedure call again, fixes #22474 (#22480)Jason Beetham2023-08-151-0/+32
| | | Ping @narimiran please backport to the 2.0 line.