summary refs log tree commit diff stats
path: root/compiler/semexprs.nim
Commit message (Collapse)AuthorAgeFilesLines
* alias syntax fixes, improvements and tests (#21671)metagn2023-04-221-7/+13
| | | | | | | | | | | | | * 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.}
* warn on set types bigger than max size, default to 0..255 for int literals ↵metagn2023-04-171-14/+19
| | | | | | | | | | | | | | | | | | | (#21659) * test implicitly huge set types refs https://github.com/nim-lang/RFCs/issues/298 * oh my god * boot at least * don't error, fix remaining issues, no 2 len arrays * fix runnable example * test assuming 0..255 for int literal * test refactor, add changelog, test
* fixes #21674; `lent` can be used in the fields or the cast type as a ↵ringabout2023-04-181-1/+1
| | | | | | | | | parameter (#21684) * fixes #21674; `lent` can be used in the fields or the cast type as a parameter * add a test case * fix the test
* set module symbol type to None instead of nil for discard check (#21657)metagn2023-04-131-0/+6
| | | | | | | * set module symbol type to None instead of nil fixes #19225 * alright
* `proc` typeclass accounts for `iterator`, call conventions + `nil` fix + ↵metagn2023-04-111-0/+1
| | | | | | | | | | | | | document typeclass AST (#21629) * test fix #16546 #16548 + another issue * please don't tell me other packages do this * fix CI + test typeclass callconv pragma * better logic in parser * docs and changelog
* tuple unpacking for vars as just sugar, allowing nesting (#21563)metagn2023-03-281-1/+1
| | | | | | | | | | | | | | | | | | | * 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
* fixes #14255; Crash in compiler when using `system.any` by accident. (#21562)ringabout2023-03-231-1/+1
| | | fixes #14255; Crash in compiler when using system.any by accident.
* Use `analyseIfAddressTaken` logic for checking if address is taken in ↵Jake Leahy2023-03-201-9/+15
| | | | | | | | | | | | | | | | | | | converter (#21533) * Add a test case There are way more test cases (See all branches of analyseIfAddressTaken but this covers at least a second branch * Port analyseIfAddressTaken from semexprs to sigmatch This was done since we cannot import sem or semexprs (circular import) but we need the rest of the logic. In needs to be done here since the converter isn't semmed afterwards and so we can't just leave the process til later use the version from semexprs * Less hacky solution which has the checking be done in analyseIfAddressTakenInCall This was done instead of the recommendation on removing it since sfAddrTaken is used in places other than the backend * Remove weird whitespace * Still check nkHiddenAddr if we are checking a converter
* fixes quoted variables with typedesc types (#21493)ringabout2023-03-091-1/+1
|
* fixes #21377; fixes `@[]` and `{}` type inference as returns in generics ↵ringabout2023-03-061-1/+1
| | | | | | | | | | | | | (#21475) * fixes `@[]` type inference in generics * add issue links * fixes macros and iterators * refactor * add one more test
* fixes #21326; fixes #7375; fixes #11986; fixes #9607; rework quote do; ↵ringabout2023-03-021-4/+7
| | | | | | | | | | | | | `getAst` uses type info to annotate the type of quoted variables; no more type erasures for quoted variables (#21433) * fixes #21326; getAst uses type info to annotateType quoted variables * simplify logics; sem types first * fixes important packages * add testcases * tiny
* Implemented basic macro expand functionality (#20579)Ivan Yonchovski2023-01-271-1/+29
| | | | | | | | | | | | | | | | | | * 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
* fix #21109 (#21127)Bung2022-12-191-0/+2
|
* fix #20588 (#21104)Bung2022-12-151-0/+2
|
* fix #15836 proc arg return type auto unexpectly match proc with concr… ↵Bung2022-12-121-2/+4
| | | | | | | | | (#21065) * fix #15836 proc arg return type auto unexpectly match proc with concrete type * fix #16244 * add test case for #12869
* fix #16758 Nim crashes in fixAbstractType (#20855)Bung2022-12-111-0/+3
| | | | | | | | | * fix #16758 Nim crashes in fixAbstractType * Update compiler/semexprs.nim Co-authored-by: Andreas Rumpf <rumpf_a@web.de> Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* 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
* fixes #21027; cast expressions need a type (#21029)ringabout2022-12-061-0/+2
| | | | | | | * fixes #21027; cast expressions need a type * Apply suggestions from code review Thanks to @beef331
* definite assignment analysis for let (#21024)ringabout2022-12-061-9/+18
| | | | | | | | | | | | | | | | | | | * 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-10/+5
| | | | | | | | | | | | | | | | | * 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
* better procvar ambiguity errors, clean up after #20457 (#20932)metagn2022-12-011-13/+34
| | | | | | | | | | | | | | | * 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
* fix bugs with dot & call operators [backport] (#20931)metagn2022-11-281-3/+6
| | | | | | | | | | | | | | | | | | | * better error messages for dot operators [backport] fixes #13063 * also fixes #7777 * fix #6981 and #9831 too * fix * minor improvement * sus test fixes * make test multiplatform lol * fix nimsuggest test, extra improvements
* Add `nkFastAsgn` into `semExpr` (#20939)Jake Leahy2022-11-271-1/+1
| | | | | * Add nkFastAsgn into case statement * Add test case
* An unnamed break in a block now gives an `UnnamedBreak` warning (#20901)ringabout2022-11-241-0/+3
| | | | | | | | | | | | | | | | | | | | | * 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
* fixes #20807, refs #20450, regression with seq inference (#20818)metagn2022-11-121-1/+5
|
* fixes #20681; add efSkipFieldVisibilityCheck to skip check (#20639)ringabout2022-10-281-1/+2
| | | | | | | | | | | | | | | | | * don't sem const objectConstr defaults * fixes * add `efSkipFieldVisibilityCheck`; fixes nkBracket types * fixes #20681 * fixes tests * suggestion from @metagn * fixes tests Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
* fixes #20645 (#20646)Andreas Rumpf2022-10-241-5/+12
| | | | | * fixes #20645 * better bugfix
* Fix #12517 Allow single branch when nimvm statements (#20577)Can Lehmann2022-10-171-3/+6
| | | Allow single branch when statements
* fixes #3748 (#20563)Andreas Rumpf2022-10-141-3/+4
| | | | | | | | | * fixes #3748 * fix the regression * don't use the new allocator for the SSL wrapper * fixes regression
* Automatic dereferencing is removed (#20531)ringabout2022-10-101-6/+0
|
* fix #18886 crash on ambiguous proc cast (#20472)Bung2022-10-101-0/+2
| | | | | * fix #18886 crash on ambiguous proc cast * follow suggestion
* add default field support for object in ARC/ORC (#20480)ringabout2022-10-041-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* closed ambiguous enum defaults to first overload (#20457)metagn2022-10-011-0/+8
| | | | | | | | | * closed ambiguous enum defaults to first overload * add warning * turn to hint * work around config
* store full definition AST for consts, fix noRewrite (#20115)metagn2022-09-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | * 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
* Update message for checking `cast` (#20145)konsumlamm2022-09-281-5/+5
| | | | | * Update message for checking `cast` * Update error messages in tests
* no ropes WIP (#20433)Andreas Rumpf2022-09-271-2/+2
| | | | | | | | | | | | | * refactorings in preparation for ropes elimination of the C code generator; mostly the usual ': Rope' -> 'result: var Rope' rewrite * rewrote ccgcalls.nim * refactored ccgexprs.nim * ccgliterals: refactoring * refactoring: code dealing with name mangling * refactoring: getRecordFieldsAux * ropes are strings (insert obscene joke here) * optimize JS code gen * optimizations and code improvements * more optimizations * final cleanups
* minor improvements to follow up recent PRs (#20342)metagn2022-09-141-1/+1
| | | | | | put mOpenArrayToSeq in compile-time evaluation whitelist (it was mNone before which was whitelisted), homogenize "ordinal type expected" errors, put overloadable enums in non-experimental manual
* overloadable enums no longer experimental (#20298)metagn2022-09-051-4/+1
| | | depends on #20126
* only allow enums to overload enums + extra test (#20126)metagn2022-09-031-2/+2
| | | mirror behavior without overloadableEnums
* top-down type inference, implements rfc 149 (#20091)metagn2022-08-241-122/+220
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* new .redefine pragma for templates, warn on redefinition without it (#20211)metagn2022-08-231-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * test CI for template redefinitions * adapt asyncmacro * fix quote * fix again * try something else * revert * fix ioselectors_select, disable packages CI * adapt more tests & simplify * more * more * more * rename to redefine, warn on implicit redefinition * basic documentation [skip ci] * Update compiler/lineinfos.nim Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
* remove {.this.} pragma, deprecated since 0.19 (#20201)metagn2022-08-231-27/+0
| | | Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Warn when casting to a larger type (#20103)konsumlamm2022-07-281-8/+10
| | | | | * Warn when casting to a larger type * Revert change to error message to fix CI
* Change `styleCheck` to ignore foreign packages (#19822)quantimnot2022-07-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* allow dots in defined() (#20010)metagn2022-07-121-1/+13
| | | | | | | * allow dots in defined() refs https://github.com/nim-lang/RFCs/issues/181 * mention accents in older versions
* Allow recursive closure iterators (#19939)Tanguy2022-06-301-1/+2
|
* Fix fixAbstractType for user defined typeclasses, fixes #19730 & #18409 (#19732)nc-x2022-04-301-1/+1
|
* Make sure that field usage preserves the original line info (#19751)Ivan Yonchovski2022-04-291-0/+2
| | | | Currently `struct.field` will generate a node with `info` that points to the symbol definition instead of having the actual node location.
* fix stylecheck bug with nre (#19356)flywind2022-04-081-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stylecheck usages part two: stdlib cleanup typeinfo.nim: importCompilerProc => importcompilerproc nre.nim: newLineFlags => newlineFlags system.nim: JSRoot => JsRoot ref #19319 * prefer importCompilerProc * fix stylecheck error with asyncdispatch it is a partial regression since #12842 * add tests * don't use echo in tests * fix stylecheck bug with nre * Update compiler/linter.nim * no need to check dotexpr again * neither did let/var/const