summary refs log tree commit diff stats
path: root/compiler/sem.nim
Commit message (Collapse)AuthorAgeFilesLines
* prepare for the enforcement of `std` prefix (#22873)ringabout2023-10-291-6/+5
| | | follow up https://github.com/nim-lang/Nim/pull/22851
* Instantiates generics in the module that uses it (#22513)Juan M Gómez2023-09-091-1/+2
| | | | | | | | | | 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>
* minor refactoring, move some sym/type construction to semdata (#22654)metagn2023-09-071-10/+0
| | | | | | | | | | Move `symFromType` and `symNodeFromType` from `sem`, and `isSelf` and `makeTypeDesc` from `concepts` into `semdata`. `makeTypeDesc` was moved out from semdata [when the `concepts` module was added](https://github.com/nim-lang/Nim/commit/6278b5d89af38e90aa30cfc4c217a2f4b1323339), so its old position might have been intended. If not, `isSelf` can also go in `ast`.
* Exclude block from endsInNoReturn, fix regression (#22632)SirOlaf2023-09-021-1/+1
| | | Co-authored-by: SirOlaf <>
* Fix #22604: Make endsInNoReturn traverse the tree (#22612)SirOlaf2023-09-011-5/+54
| | | | | | | | | | | | | | | | | * 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 <>
* fix generic param substitution in templates (#22535)metagn2023-08-251-1/+7
| | | | | | | * 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
* fix #22448 Remove `structuredErrorHook` temporary in `tryConstExpr` (#22450)Pylgos2023-08-111-0/+9
| | | | | * fix #22448 * add test
* `initNodeTable` and friends now return (#22444)ringabout2023-08-111-1/+1
|
* replaces `doAssert false` with `raiseAssert` for unreachable branches, which ↵ringabout2023-08-101-2/+2
| | | | | works better with strictdefs (#22436) replaces `doAssert false` with `raiseAssert`, which works better with strictdefs
* use strictdefs for compiler (#22365)ringabout2023-08-061-2/+20
| | | | | | | | | | | | | | | * wip; use strictdefs for compiler * checkpoint * complete the chores * more fixes * first phase cleanup * Update compiler/bitsets.nim * cleanup
* fixes #22301; fixes #22324; rejects branch initialization with a runtime ↵ringabout2023-07-251-16/+18
| | | | | | | | | | | discriminator with defaults (#22303) * fixes #22301; rejects branch initialization with a runtime discriminator with defaults * undefault nimPreviewRangeDefault * fixes tests * use oldCheckDefault
* fixes #22123; Compiler bug with default initializer values and arrays (#22128)ringabout2023-06-201-4/+4
|
* fix scoping regression with calls in generic bodies (#22115)metagn2023-06-171-2/+2
| | | refs #22029, refs https://github.com/status-im/nim-libp2p/actions/runs/5263850340/jobs/9514434659
* strictly typecheck expressions in bracketed `emit` (#22074)metagn2023-06-131-0/+1
| | | | | * strictly typecheck expressions in bracketed `emit` * use nim check in test
* Remove Deprecated Nimfix (#22062)Juan Carlos2023-06-101-2/+0
| | | | * Remove Deprecated Nimfix * Trailing whitespace cleanups
* support generic void return type for templates (#21934)metagn2023-05-271-2/+5
| | | fixes #21920
* fixes #21840; nested local template lookup regression (#21841)ringabout2023-05-121-7/+7
| | | | | | | * fixes #21840; nested local template lookup regression * use original types * fixes js vm tests
* refactoring in preparation for better, simpler name mangling that wor… ↵Andreas Rumpf2023-04-241-3/+5
| | | | | | | | | | | (#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
* fixes #3770; templates with untyped parameters resolve private fields ↵ringabout2023-03-211-4/+4
| | | | | | | | | wrongly in generics (#21554) * fixes #3770; templates with untyped parameters resolve private fields wrongly * add a test case for #3770 * rename to `nfSkipFieldChecking`
* remove nosinks hacks from compiler (#21469)ringabout2023-03-041-2/+2
|
* replaces implicit passes array registed at runtime with explicit function ↵ringabout2023-03-031-37/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | calls; simplify compilation pipeline (#21444) * abolish using passes in the compiler; simplify compilation pipeline * duplicate code * Really cool to have the same signature... * haul * unify other backends * refactor process * introduce PipelinePhase * refactor compiler * fixes passes * fixes nimsuggest * add a sentinel * enable docs checkj * activate doc testing * clean up * complete cleanups
* fixes #19795; fixes #11852; fixes #19974; remove parsing pipeline, Nim now ↵ringabout2023-02-221-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | parses the whole module at one time (#21379) * fixes #19795; remove parse pipeline * isScript * fixes nimscriptapi * don't touch reorder * check script * fixes tests * it seems implicit imports of system cause troubles * access the first child of `nkStmtList` * ignore comments * minor messages * perhaps increases hloLoopDetector * the module is a stmtList, which changes the errors * fixes nimdoc * fixes tlinter * fixes nim secret tests * fixes arc_misc * fixes nim secret tests again * safe; fixes one more test * GlobalError is the root cause too * fixes parsing errors * put emit types to the cfsForwardTypes section * fixes #11852; `{.push checks:off}` now works in procs * disable navigator * fixes nimdoc * add tests for JS * fixes nimsuggest
* fixes #21260; add check for illegal recursion for defaults (#21270)ringabout2023-01-181-22/+14
| | | | | * fixes #21260; add check for illegal recursion for defaults * fixes differently
* remove legacy code (#21134)ringabout2022-12-261-3/+0
| | | | | * remove legacy code * fixes
* fix #15836 proc arg return type auto unexpectly match proc with concr… ↵Bung2022-12-121-2/+2
| | | | | | | | | (#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-2/+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/+2
| | | | | (#21044) fix #15836 proc arg return type auto unexpectly match proc with concrete type
* unpublic `arrayWith` and rename it to `nimArrayWith` (#21006)ringabout2022-12-041-4/+4
| | | | | * unpublic arrayWith * unindent
* fixes object default fields bugs and add tests (#20839)ringabout2022-11-151-15/+24
| | | | | | | | | | | * fixes object default fields bugs and add tests * Update compiler/semmagic.nim * Update compiler/sem.nim * Update compiler/sem.nim Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fixes #20715; range[a..b] inside object variant fails (#20716)ringabout2022-10-311-5/+6
| | | | | | | | | | | * fixes #20715; range[a..b] inside object variant fails * step one fix * better fix * fixes private fields * mistake
* add default field support for object in ARC/ORC (#20480)ringabout2022-10-041-0/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* move formatfloat out of system (#20195)ringabout2022-08-241-0/+3
| | | | | | | | | | | | | | | * move formatfloat out of system * fixes doc * Update changelog.md * careless * fixes * deprecate system/formatfloat * better handling
* top-down type inference, implements rfc 149 (#20091)metagn2022-08-241-22/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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 'lent T' inside object constructor [backport] (#18911)Andreas Rumpf2021-09-271-1/+2
| | | | | * fixes 'lent T' inside object constructor [backport] * progress
* Fixed type inference for 'set` and 'tuple' (#18827)Jason Beetham2021-09-111-1/+2
| | | | | | | * improved built in typeclass inference * Smarter logic to fit node * Forgot the untyped check
* fixes #12642 (#18811)Andreas Rumpf2021-09-061-0/+6
| | | | | | | | | | | | | | | | | | | * fixes #12642 * update important packages; refs #18804 * fixes #18805; refs #18806 * fixes a regression * Update testament/categories.nim Co-authored-by: flywind <xzsflywind@gmail.com> * progress * progress Co-authored-by: flywind <xzsflywind@gmail.com>
* strict effects (#18777)Andreas Rumpf2021-09-021-3/+4
| | | | | | | | | | | | | | | | | * fixes #17369 * megatest is green for --cpu:arm64 * docgen output includes more tags/raises * implemented 'effectsOf' * algorithm.nim: uses new effectsOf annotation * closes #18376 * closes #17475 * closes #13905 * allow effectsOf: [a, b] * added a test case * parameters that are not ours cannot be declared as .effectsOf * documentation * manual: added the 'sort' example * bootstrap with the new better options
* implements overloadable enum values; WIP (#18470)Andreas Rumpf2021-07-281-0/+8
| | | | | * implements overloadable enum values * simpler code
* fixes #15884 (#18230)Andreas Rumpf2021-06-101-0/+9
| | | | | * fixes #15884 * micro optimization
* add astmsgs; add `declared in` msg for usage lint errors (#17961)Timothee Cour2021-05-081-1/+1
| | | | | | | | | * add astmsgs; add `declared in` msg for usage lint errors * fix test * fix tests/tools/tlinter.nim * std prefix
* `typeof(voidStmt)` now works (#17807)Timothee Cour2021-04-231-0/+1
| | | | | | | | * `typeof(voidStmt)` now works * remove typeOrVoid * add condsyms, and reference cligen https://github.com/c-blake/cligen/pull/193 * fixup * changelog [skip ci] * fixup
* Introduce localErrorNode (#17785)Clyybber2021-04-191-2/+1
|
* IC: first steps towards 'nim check --def --ic:on' (#17714)Andreas Rumpf2021-04-141-0/+1
| | | | | | | | | * IC: first steps towards 'nim check --def --ic:on' * IC navigator: deduplicate output lines * IC navigator: progress * IC navigator: use a different nimcache entry * IC navigator: special logic for templates/macros * IC navigator: proper error messages * IC navigator: prepare for testing code; document only what currently works somewhat
* IC: backend: remember produced type information (#17440)Andreas Rumpf2021-03-231-1/+1
|
* semTemplateDef and t17433 clean-ups (#17448)Saem Ghani2021-03-221-2/+22
| | | | | - use `doAssert` in t17433 - use setGenericParamsMisc in semTemplateDef akin to semProcAux - pragma handling in semTemplateDef inline with semProcAux
* semLambda removed, semProcAux reworked (#17379)Saem Ghani2021-03-171-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * simplified proc-like name ident to symbol code * wip - reworking generic param sem * wip - closer to removing nkEmpty generic params * it's hacky but tests pass * slowly tweaking semProcAux to take on semLambda * fix pragma superset check proto vs current * Set the symbol owner earlier * partial progress reworking proto found bug where default values between forward and impl lead to overload resolution issues. * simplified pragma handling and callConv checks Co-authored-by: Clyybber <Clyybber@users.noreply.github.com> * partially working * cgexprs issue * It works! * comment clean-up * clean-up asserts, comments, and other bits * add isGenericParams, inline isGeneric queries * seeing if this is sufficiently consistent * can use this approach or continue it in a further PR * commentary about nullary generics and clean-ups * fixed a mistake in PNode isGenericRoutine * Some small cleanups * Small cleanup * for func lambdas ensure we use lambda pragmas * add some basic compileTime func tests * [ci skip] remove comments Co-authored-by: Clyybber <Clyybber@users.noreply.github.com> Co-authored-by: Clyybber <darkmine956@gmail.com>
* new-style concepts implementation, WIP (#15251)Andreas Rumpf2021-02-241-1/+1
| | | | | | | | | | | | | * fixes #15210 [backport:1.2] * make tests green * make ordinal work * makes Swapable test compile * make Indexable example work * concepts: 'self' is now 'Self' * concepts: make Dictionary example compile * document the new concept implementation * concepts: make typeDesc work properly * concepts: allow documentation comments (d'oh)
* use typeof instead type (#16962)flywind2021-02-081-1/+1
|
* IC: bugfixes (WIP) (#16836)Andreas Rumpf2021-02-021-0/+1
| | | | | | | | * minor improvements * IC: added the required logic for compilerProcs * LazySym ftw * we need this testing logic * reimplement the old way we use for module package creation * fixes a regression; don't pick module names if you can avoid it
* IC: next steps (#16729)Andreas Rumpf2021-01-231-6/+6
| | | | | | | | | | | * IC: dead code elimination pass * preparations for a different codegen strategy * added documentation to the newly written code * IC: backend code * IC: backend adjustments * optimized the compiler a bit * IC: yet another massive refactoring * fixes regressions * cleanups