summary refs log tree commit diff stats
path: root/compiler/semstmts.nim
Commit message (Collapse)AuthorAgeFilesLines
* 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
* fixes #9839; fixes noReturn pragma doesn't work for non-simple templates ↵ringabout2022-12-081-3/+6
| | | | (#21048)
* definite assignment analysis for let (#21024)ringabout2022-12-061-9/+10
| | | | | | | | | | | | | | | | | | | * draft for let daa * patch * fixes bugs * errors for global let variable reassignments * checkpoint * out param accepts let * add more tests * add documentation * merge tests
* deprecate `do:` meaning `do ():` + misc cleanup (#20927)metagn2022-12-061-34/+0
| | | | | | | | | | | | | | | | | * test disable do: block lambda lifting * fix last test [skip ci] * deprecate `do:` meaning `do ():` + misc cleanup closes https://github.com/nim-lang/RFCs/issues/486 * oops * fix * no idea what could be causing nimsuggest failure other than this * ensure ci works
* fixes `isLocalVarSym`; an implicit global is a global nonetheless (#21025)ringabout2022-12-051-2/+2
| | | fixes isLocalVarSym; an implicit global is a global nonetheless
* ref #20846; give a deprecation message for overriding `=` hook (#21020)ringabout2022-12-051-0/+2
| | | give a deprecation message for overriding `=` hook
* fix #20996 (#21016)metagn2022-12-041-1/+1
| | | | | * fix #20996 * hopefully fix
* better procvar ambiguity errors, clean up after #20457 (#20932)metagn2022-12-011-21/+3
| | | | | | | | | | | | | | | * better procvar ambiguity errors, clean up after #20457 fixes #6359, fixes #13849 * only trigger on closedsymchoice again * new approach * add manual entry for ambiguous enums too * add indent [skip ci] * move to proc
* fixes #13583; enforce void for `nkWhileStmt` (#20947)ringabout2022-11-291-0/+5
| | | | | * fixes #13583; enfore void for nkWhileStmt * one more case
* An unnamed break in a block now gives an `UnnamedBreak` warning (#20901)ringabout2022-11-241-0/+8
| | | | | | | | | | | | | | | | | | | | | * unnamed break in the block now gives an error * bootstrap * fixes * more fixes * break with label * label again * one moee * Delete test5.txt * it now gives a UnnamedBreak warning * change the URL of bump back to the original one
* fix #18964 Small string case with else statement first in AST evaluat… ↵Bung2022-11-221-1/+6
| | | | | (#20862) fix #18964 Small string case with else statement first in AST evaluates wrongly
* fix #20866 [ORC] Bad codegen for global pointer to iterator (#20876)Bung2022-11-221-2/+5
|
* fix #3505 wrong var {.global.} initialization, asign variable to it (#20812)Bung2022-11-121-1/+21
| | | | | | | | | | | | | | | | | | | | | | | * fix #3505 wrong var {.global.} initialization, asign variable to it * fix #5132 as well * follow suggestions * handle all call kinds * Update tests/global/t3505.nim * Update compiler/semstmts.nim * Update compiler/semstmts.nim * Update compiler/semstmts.nim * follow suggestion * Update compiler/semstmts.nim Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fix semcase on tySequence and tyObject #20283 #19682 (#20339)Bung2022-11-011-8/+8
| | | | | | | | | | | | | * fix semcase on tySequence and tyObject #20283 #19682 * use better arg name * avoiding returns nil use errorNode instead, clean code * use efNoDiagnostics flag * remove tests/errmsgs/t19682.nim * combine 2 test cases to one file
* alternate fix + test for #12094, refs #13804 (#20686)metagn2022-10-291-2/+1
|
* fix #12094 Use of _ (as var placeholder) inside a template causes XDe… ↵Bung2022-10-251-1/+2
| | | | | (#20635) fix #12094 Use of _ (as var placeholder) inside a template causes XDeclaredButNotUsed
* borrowed procs can have a body now for documentation generation (#20617)ringabout2022-10-241-2/+3
| | | | | * borrowed procs can have a body now * fixes examples
* remove implicit let/var default initialization (#20508)ringabout2022-10-071-11/+0
|
* add default field support for object in ARC/ORC (#20480)ringabout2022-10-041-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * fresh start * add cpp target * add result support * add nimPreviewRangeDefault * reduce * use orc * refactor common parts * add tuple support * add testcase for tuple * cleanup; fixes nimsuggest tests * there is something wrong with cpp * remove * add support for seqs * fixes style * addd initial distinct support * remove links * typo * fixes tuple defaults * add rangedefault * add cpp support * fixes one more bugs * add more hasDefaults * fixes ordinal types * add testcase for #16744 * add testcase for #3608 * fixes docgen * small fix * recursive * fixes * cleanup and remove tuple support * fixes nimsuggest * fixes generics procs * refactor * increases timeout * refactor hasDefault * zero default; disable i386 * add tuples back * fixes bugs * fixes tuple * add more tests * fix one more bug regarding tuples * more tests and cleanup * remove messy distinct types which must be initialized by original types * add tests * fixes zero default * fixes grammar * fixes tests * fixes tests * fixes tests * fixes comments * fixes and add testcase * undo default values for results Co-authored-by: flywind <43030857+xflywind@users.noreply.github.com>
* pragma for sfCallsite instead of name check + better semantics, test (#20464)metagn2022-10-031-6/+1
| | | | | | | | | | | * pragma for sfCallsite instead of name check at every template definition Not documented because it seems to be for internal use? Should also make it possible to make comparisons and setops imports, but this doesn't have to be done. I can reuse a name like `cursor` for the pragma as well, added a new name just to be safe. * make sfCallsite recursive, add tests
* Fix #19224 For loops over a hardcoded empty array crash the compiler (#20476)Bung2022-10-011-0/+3
| | | | | * Fix #11684 For loops over a hardcoded empty array crash the compiler * Update t19224.nim
* closed ambiguous enum defaults to first overload (#20457)metagn2022-10-011-5/+9
| | | | | | | | | * closed ambiguous enum defaults to first overload * add warning * turn to hint * work around config
* koch boot compiler with orc (#20467)ringabout2022-09-301-1/+1
| | | | | | | | | | | * koch boot compiler with orc * use orc * workaround bugs * move it * move the data
* store full definition AST for consts, fix noRewrite (#20115)metagn2022-09-281-17/+28
| | | | | | | | | | | | | | | | | | | | | | | * continue #9582 for consts, close #9331, fix #20114 also move extractPragma to ast to pave the way for things like {.strdefine: "abc".} etc * changelog correctly * fix jsgen * update tgetimpl * fix sighashes * fix #19766, add comment about postfix * fix noRewrite LOL refs #16620 * fix changelog * fix destructors
* Fixes #20348; only respect the recursion limit if the symbol's generic type ↵Aditya Siram2022-09-221-0/+1
| | | | | has been generated by the compiler (#20377) Fixes #20348
* report expression has no type other than has to be used (or discarded… ↵Bung2022-09-201-0/+3
| | | | | (#20392) report expression has no type other than has to be used (or discarded) when typ is tyNone in discardCheck
* remove deprecated type pragma syntax, fix bugs that required it (#20199)metagn2022-09-031-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | * remove deprecated pragma syntax from 0.20.0 closes #4651, closes #16653 with a cheap fix for now due to how early `tfFinal` is set * remove type pragma between name and generics * undo removal, try removing bind expression (0.8.14) * fix test, unremove bind expr * remove again * Update changelog.md Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> * dependencies @ HEAD & weave test dependencies * try fix package ci Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
* support cstring in `case` (#20130)metagn2022-09-011-1/+1
| | | | | | | | | | | | | | | * implement case for cstring for now just converts to string on C backend * custom implementation for cstring * remove leftover * revert even more * add nil + fix packages weird variant literal bug * update docs
* top-down type inference, implements rfc 149 (#20091)metagn2022-08-241-28/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * micro implementation of rfc 149 refs https://github.com/nim-lang/RFCs/issues/149 * number/array/seq literals, more statements * try fix number literal alias issue * renew expectedType with if/case/try branch types * fix (nerf) index type handling and float typed int * use typeAllowed * tweaks + const test (tested locally) [skip ci] * fill out more of the checklist * more literals, change @ order, type conversions Not copying the full call tree before the typedesc call check in `semIndirectOp` is also a small performance improvement. * disable self-conversion warning * revert type conversions (maybe separate op later) * deal with CI for now (seems unrelated), try enums * workaround CI different way * proper fix * again * see sizes * lol * overload selection, simplify int literal -> float * range, new @ solution, try use fitNode for nil * use new magic * try fix ranges, new magic, deal with #20193 * add documentation, support templates Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fixes #20031; uint64 is an ordinal type since 1.0 (#20094)ringabout2022-07-271-1/+1
| | | | | * fixes #20031; uint64 is an ordinal type since 1.0 * Update compiler/semstmts.nim
* .forbids pragma: defining forbidden tags (#20050)Lancer112112022-07-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * .forbids pragma: defining illegal effects for proc types This patch intends to define the opposite of the .tags pragma: a way to define effects which are not allowed in a proc. * updated documentation and changelogs for the forbids pragma * renamed notTagEffects to forbiddenEffects * corrected issues of forbids pragma the forbids pragma didn't handle simple restrictions properly and it also had issues with subtyping * removed incorrect character from changelog * added test to cover the interaction of methods and the forbids pragma * covering the interaction of the tags and forbids pragmas * updated manual about the forbids pragma * removed useless statement * corrected the subtyping of proc types using the forbids pragma * updated manual for the forbids pragma * updated documentations for forbids pragma * updated nim docs * updated docs with rsttester.nim * regenerated documentation * updated rst docs * Update changelog.md Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> * updated changelog * corrected typo Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* Change `styleCheck` to ignore foreign packages (#19822)quantimnot2022-07-141-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Change `styleCheck` to ignore foreign packages * Symbols from foreign packages are now ignored. * Fixed `styleCheck` violations in `compiler` package. * Added symbol ownership to custom annotation pragmas. * Minor refactors to cleanup style check callsites. * Minor internal documentation of reasons why a symbol isn't checked. Style violations were fixed in the compiler after thet were exposed by the changes. The compiler wouldn't compile otherwise. Symbol ownership for custom pragma annotations is needed for checking the annotation's style. A NPE was raised otherwise. Fixes #10201 See also nim-lang/RFCs#456 * Fix a misunderstanding about excluding field style checks I had refactored the callsites of `styleCheckUse` to apply the DRY principle, but I misunderstood the field access handling in a template as a general case. This corrects it. * Fix some `styleCheck` violations in `compiler/evalffi` The violations were exposed in CI when the compiler was built with libffi. * Removed some uneeded transitionary code * Add changelog entry Co-authored-by: quantimnot <quantimnot@users.noreply.github.com>
* give a better error message for some template expansions (#19871)Andreas Rumpf2022-06-091-2/+4
|
* [nimsuggest] return the type when on symbol in let/var (#19639)Ivan Yonchovski2022-04-071-3/+6
| | | - make sure `suggestSym` is called after `PSym.typ` is set.
* nvro don't touch cdecl types [backport: 1.6] (#19461)flywind2022-01-281-0/+1
| | | * nvro don't touch cdecl types; fix #19342 again
* New/better macro pragmas, mark some as experimental (#19406)metagn2022-01-201-116/+170
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * New/better macro pragmas, make some experimental fix #15920, close #18212, close #14781, close #6696, close https://github.com/nim-lang/RFCs/issues/220 Variable macro pragmas have been changed to only take a unary section node. They can now also be applied in sections with multiple variables, as well as `const` sections. They also accept arguments. Templates now support macro pragmas, mirroring other routine types. Type and variable macro pragmas have been made experimental. Symbols without parentheses instatiating nullary macros or templates has also been documented in the experimental manual. A check for a redefinition error based on the left hand side of variable definitions when using variable macro pragmas was disabled. This nerfs `byaddr` specifically, however this has been documented as a consequence of the experimental features `byaddr` uses. Given how simple these changes are I'm worried if I'm missing something. * accomodate compiler boot * allow weird pragmas * add test for #10994 * remove some control flow, try remove some logic
* `caseStmtMacros` no longer experimental, experimental manual refactor (#19173)hlaaftana2021-11-231-4/+4
| | | | | | | | | | | * `caseStmtMacros` no longer experimental, experimental manual refactor * Update doc/manual.rst * apply review suggestions * apply review Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Accept nnkTypeSection from typedef macro pragmas (#19168)hlaaftana2021-11-221-5/+13
|
* fixes 'lent T' inside object constructor [backport] (#18911)Andreas Rumpf2021-09-271-1/+1
| | | | | * fixes 'lent T' inside object constructor [backport] * progress
* correct effect tracking for .borrowed procs [backport] (#18882)Andreas Rumpf2021-09-231-1/+4
| | | | | | | | | | | * correct effect tracking for .borrowed procs [backport] * progress * fix error message in a test * correctly fix it Co-authored-by: narimiran <narimiran@disroot.org>
* fixes #18863 [backport] (#18871)Andreas Rumpf2021-09-201-1/+1
|