summary refs log tree commit diff stats
path: root/compiler/semstmts.nim
Commit message (Collapse)AuthorAgeFilesLines
* suppress incorrect var T destructor warnings for newFinalizer in stdlib (#22810)ringabout2023-10-111-2/+2
| | | | | | | | | | | | in `std/nre` ```nim proc initRegex(pattern: string, flags: int, study = true): Regex = new(result, destroyRegex) ``` gives incorrect warnings like ``` C:\Users\blue\Documents\Nim\lib\impure\nre.nim(252, 6) Error: A custom '=destroy' hook which takes a 'var T' parameter is deprecated; it should take a 'T' parameter [Deprecated ```
* fixes compiler crash by preventing exportc on generics (#22731)Juan M Gómez2023-09-201-3/+6
| | | Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* `constructor` now uses `result` instead of `this` (#22724)Juan M Gómez2023-09-191-28/+8
|
* prevents declaring a constructor without importcpp fixes #22712 (#22715)Juan M Gómez2023-09-181-2/+7
| | | Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* implements RFC: [C++] Constructors as default initializers (#22694)Juan M Gómez2023-09-141-29/+50
| | | Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fixes #22669 constructor pragma doesnt init Nim default fields (#22670)Juan M Gómez2023-09-101-0/+2
| | | | | | | fixes #22669 constructor pragma doesnt init Nim default fields --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* don't update const symbol on const section re-sems (#22609)metagn2023-09-011-5/+10
| | | fixes #19849
* Fix #22604: Make endsInNoReturn traverse the tree (#22612)SirOlaf2023-09-011-3/+1
| | | | | | | | | | | | | | | | | * 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-011-2/+8
| | | | | | | | | * type annotations for variable tuple unpacking, better error messages closes #17989, closes https://github.com/nim-lang/RFCs/issues/339 * update grammar * fix test
* round out tuple unpacking assignment, support underscores (#22537)metagn2023-08-241-7/+10
| | | | | | | | | | | | | | | * 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>
* unpublic the sons field of PType; the precursor to PType refactorings (#22446)ringabout2023-08-111-7/+7
| | | | | | | | | | | * unpublic the sons field of PType * tiny fixes * fixes an omittance * fixes IC * fixes
* fix #19304 Borrowing std/times.format causes Error: illformed AST (#20659)Bung2023-08-101-12/+21
| | | | | | | | | * fix #19304 Borrowing std/times.format causes Error: illformed AST * follow suggestions * mitigate for #4121 * improve error message
* [C++] Member pragma RFC (https://github.com/nim-lang/RFCs/issues/530) (#22272)Juan M Gómez2023-08-071-7/+8
| | | | | | | | | | * [C++] Member pragma RFC #530 rebase devel * changes the test so `echo` is not used before Nim is init * rebase devel * fixes Error: use explicit initialization of X for clarity [Uninit]
* use strictdefs for compiler (#22365)ringabout2023-08-061-6/+25
| | | | | | | | | | | | | | | * wip; use strictdefs for compiler * checkpoint * complete the chores * more fixes * first phase cleanup * Update compiler/bitsets.nim * cleanup
* Check try block for endsInNoReturn (#22314)SirOlaf2023-07-221-2/+3
| | | Co-authored-by: SirOlaf <>
* fix new type inference for `noreturn` [backport] (#22182)metagn2023-06-281-7/+14
| | | | | fixes #22180 Backported since apparently the new type inference was backported
* allow destructors to accept non var parameters; deprecate `proc =destroy(x: ↵ringabout2023-06-211-1/+6
| | | | | | | | | | var T)` (#22130) * make destructors accept non var parameters * define nimAllowNonVarDestructor * add a test case and a changelog * update documentation and error messages * deprecate destructors taking 'var T'
* overhaul the error messages of `=dup` (#22129)ringabout2023-06-201-6/+41
|
* Allows for arbitrary ordering of inheritance in type section #6259 (#22070)Juan M Gómez2023-06-151-2/+3
| | | | | | | | | | | | | * Allows for arbitrary ordering of inheritance in type section #6259 * prevents ilegal recursion * fixes ilegal recursion. Test passes with a better message * Apply suggestions from code review --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* make borrow `.` work with aliases if not overriden (#22072)metagn2023-06-111-3/+8
|
* Remove Deprecated Nimfix (#22062)Juan Carlos2023-06-101-13/+7
| | | | * Remove Deprecated Nimfix * Trailing whitespace cleanups
* fixes {.global.} ref typedesc regressions (#22046)ringabout2023-06-081-0/+1
|
* fixes overriden typo (#22044)ringabout2023-06-081-6/+6
|
* properly disallow unresolved generic proc values (#22005)metagn2023-06-051-1/+0
| | | | | | | * properly disallow unresolved generic proc values * mirrors semoperand * shallow efTypeAllowed, add back special case
* Implements: [C++] constructor pragma improvement (fix #21921) (#21916)Juan M Gómez2023-05-301-18/+41
| | | | | | | | | | | | | | | * implements: [C++] constructor pragma improvement (fix #21921) t * fix test so it doesnt use echo in globals * Update compiler/ccgtypes.nim * Update lib/std/private/dragonbox.nim --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fix #21896 asign parameter to global variable generates invalid code (#21900)Bung2023-05-241-1/+1
|
* Cpp Vfunctions draft (#21790)Juan M Gómez2023-05-171-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * introduces virtual pragma, modifies proc def, prevents proc decl * marks virtual procs as infix * forward declare vfuncs inside the typedef * adds naked callConv to virtual * virtual proc error if not defined in the same top level scope as the type * first param is now this. extracts genvirtualheaderproc * WIP syntax * supports obj. Removes the need for the prefix * parameter count starts as this. Cleanup * clean up * sem tests * adds integration tests * uses constraint to store the virtual content * introduces genVirtualProcParams --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* adds documentation for `=wasMoved` and `=dup` hooks and small fixes (#21827)ringabout2023-05-111-1/+1
| | | | | | | | | | | * adds documentation for `=wasMoved` and `=dup` hooks and small fixes * Update doc/destructors.md * Update doc/destructors.md --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* implement `=dup` hook eliminating `wasMoved` and `=copy` pairs (#21586)ringabout2023-05-061-3/+13
| | | | | | | | | | | | | | | | | | | * import `=dup` hook eliminating `wasMoved` and `=copy` pairs * add dup * add a test for dup * fixes documentation * fixes signature * resolve comments * fixes tests * fixes tests * clean up
* underscore as special word (#21766)metagn2023-05-021-2/+2
| | | | | * underscore as special word * fix really hard to notice error
* fixes #21245; warn about destructors that can raise (#21726)Andreas Rumpf2023-04-261-0/+5
| | | | | | | | | * fixes #21245; warn about destructors that can raise * doc update * progress * typo
* fix #21727 (#21729)metagn2023-04-261-5/+8
|
* refactoring in preparation for better, simpler name mangling that wor… ↵Andreas Rumpf2023-04-241-8/+8
| | | | | | | | | | | (#21667) * refactoring in preparation for better, simpler name mangling that works with IC flawlessly * use new disamb field * see if this makes tests green * make tests green again
* alias syntax fixes, improvements and tests (#21671)metagn2023-04-221-1/+14
| | | | | | | | | | | | | * alias syntax fixes, improvements and tests * even better, cannot use alias syntax with generics * more type tests, improve comment * fix again * consistent error message + make t5167_5 work * more comments, remove {.noalias.}
* set module symbol type to None instead of nil for discard check (#21657)metagn2023-04-131-12/+13
| | | | | | | * set module symbol type to None instead of nil fixes #19225 * alright
* fix #15691 (#21623)metagn2023-04-111-2/+0
| | | `semProcAux` has a check for `checkMinSonsLen(n, bodyPos + 1)`
* `for` loop expression can now have generated `iterator`'s called (#21627)Jason Beetham2023-04-081-1/+2
| | | A for expression now can have a generated iterator, allowing for more composable iterables
* tuple unpacking for vars as just sugar, allowing nesting (#21563)metagn2023-03-281-85/+112
| | | | | | | | | | | | | | | | | | | * tuple unpacking for vars as just sugar, allowing nesting * set temp symbol AST * hopeful fix some issues, add test for #19364 * always use temp for consts * document, fix small issue * fix manual indentation * actually fix manual * use helper proc * don't resem temp tuple assignment
* remove nosinks hacks from compiler (#21469)ringabout2023-03-041-1/+1
|
* fixes #19291; implements `wasMoved` hook (#21303)ringabout2023-03-021-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * fixes #19291; implements `wasMoved` hook * basics * checkpoint * finish `wasMoved` * add a test for #19291 * add documentation and changelog * work `attachedWasMoved` with generics * fixes optimizer * register `=wasMoved` * handle wasMoved magcis * check another round * some patches * try `op == nil` * nicer * generate `wasMoved` before `destroy` * try again * fixes tests * default wasMoved * Update tests/destructor/tv2_cast.nim * Update tests/destructor/tv2_cast.nim * Update tests/arc/topt_refcursors.nim
* fixes #21360; discarding empty seqs/arrays now raises errors (#21374)ringabout2023-02-161-8/+10
| | | | | * discarding empty seqs now raises errors * the same goes for sets
* Revert "Fix #13093 C++ Atomics: operator= is implicitly deleted because the ↵ringabout2023-01-271-5/+1
| | | | | | | default definition would be ill-formed " (#21307) Revert "Fix #13093 C++ Atomics: operator= is implicitly deleted because the default definition would be ill-formed (#21169)" This reverts commit a7bae919adb952362cb53206140872d2b7424b47.
* Fix #13093 C++ Atomics: operator= is implicitly deleted because the default ↵Bung2023-01-271-1/+5
| | | | | | | | | | | | | definition would be ill-formed (#21169) * add test * fix #17982 Invalid C++ code generation when returning discardable var T * fix #13093 * cpp atomic good example * clearify the condition
* Implemented basic macro expand functionality (#20579)Ivan Yonchovski2023-01-271-1/+1
| | | | | | | | | | | | | | | | | | * Implemented level based macro expand functionality - it can handle single macro call or expand whole function/proc/etc and it - In addition, I have altered the parser to provide the endInfo for the node. The usefulness of the `endInfo` is not limited to the `expandMacro` functionality but also it is useful for `ideOutline` functionality and I have altered the ideOutline functionality to use `endInfo`. Note `endInfo` most of the time is lost during the AST transformation thus in `nimsuggest.nim` I am using freshly parsed tree to get the location information. * Make sure we stop expanding correctly * Test CI * Fix tv3_outline.nim
* enforce void for nkWhileStmt [backport: 2.0] (#21170)ringabout2022-12-241-1/+0
| | | enforce void for nkWhileStmt
* fix #11634 (#21146)Bung2022-12-231-3/+6
|
* fix #19580; add warning for bare except: clause (#21099)ringabout2022-12-151-1/+4
| | | | | | | | | | | | | | | | | | | | | * fix #19580; add warning for bare except: clause * fixes some easy ones * Update doc/manual.md * fixes docs * Update changelog.md * addition * Apply suggestions from code review Co-authored-by: Jacek Sieka <arnetheduck@gmail.com> * Update doc/tut2.md Co-authored-by: Jacek Sieka <arnetheduck@gmail.com>
* fix #15836 proc arg return type auto unexpectly match proc with concr… ↵Bung2022-12-121-2/+1
| | | | | | | | | (#21065) * fix #15836 proc arg return type auto unexpectly match proc with concrete type * fix #16244 * add test case for #12869
* Revert "fix #15836 proc arg return type auto unexpectly match proc with ↵ringabout2022-12-091-1/+2
| | | | | | | concr…" (#21057) Revert "fix #15836 proc arg return type auto unexpectly match proc with concr… (#21044)" This reverts commit 0cd9bdcf9f6802421e0d8e4c28fc732012af605e.
* fix #15836 proc arg return type auto unexpectly match proc with concr… ↵Bung2022-12-091-2/+1
| | | | | (#21044) fix #15836 proc arg return type auto unexpectly match proc with concrete type