summary refs log tree commit diff stats
path: root/compiler/semobjconstr.nim
Commit message (Collapse)AuthorAgeFilesLines
* fixes requiresInit for var statements without initialization (#24177)ringabout2024-09-261-4/+7
| | | ref https://forum.nim-lang.org/t/12530
* fixes #23494; Wrong type in object construction error message (#23504)ringabout2024-04-161-1/+1
| | | fixes #23494
* fixes yet another strictdefs bug (#23069)ringabout2023-12-151-1/+1
|
* type refactoring: part 2 (#23059)Andreas Rumpf2023-12-131-1/+1
|
* Types: Refactorings; step 1 (#23055)Andreas Rumpf2023-12-121-4/+4
|
* IC: progress and refactorings (#22961)Andreas Rumpf2023-11-201-1/+1
|
* prepare for the enforcement of `std` prefix (#22873)ringabout2023-10-291-1/+1
| | | follow up https://github.com/nim-lang/Nim/pull/22851
* NIR: Nim intermediate representation (#22777)Andreas Rumpf2023-10-111-9/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Theoretical Benefits / Plans: - Typed assembler-like language. - Allows for a CPS transformation. - Can replace the existing C backend by a new C backend. - Can replace the VM. - Can do more effective "not nil" checking and static array bounds checking. - Can be used instead of the DFA. - Easily translatable to LLVM. - Reasonably easy to produce native code from. - Tiny memory consumption. No pointers, no cry. **In very early stages of development.** Todo: - [x] Map Nim types to IR types. - [ ] Map Nim AST to IR instructions: - [x] Map bitsets to bitops. - [ ] Implement string cases. - [ ] Implement range and index checks. - [x] Implement `default(T)` builtin. - [x] Implement multi string concat. - [ ] Write some analysis passes. - [ ] Write a backend. - [x] Integrate into the compilation pipeline.
* fixes #22613; Default value does not work with object's discriminator (#22614)ringabout2023-09-011-23/+43
| | | | | | | | | | | | | | | * 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
* use strictdefs for compiler (#22365)ringabout2023-08-061-9/+18
| | | | | | | | | | | | | | | * 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-1/+12
| | | | | | | | | | | discriminator with defaults (#22303) * fixes #22301; rejects branch initialization with a runtime discriminator with defaults * undefault nimPreviewRangeDefault * fixes tests * use oldCheckDefault
* fixes ilegal recursion (#22105)Juan M Gómez2023-06-161-1/+3
|
* fixes #20900; Calling template through from generic function across module ↵ringabout2023-04-131-0/+1
| | | | | | | fails to build (#21649) * fixes #20900; Calling template through from generic function across module fails to build * sanother way
* fixes #3770; templates with untyped parameters resolve private fields ↵ringabout2023-03-211-2/+2
| | | | | | | | | wrongly in generics (#21554) * fixes #3770; templates with untyped parameters resolve private fields wrongly * add a test case for #3770 * rename to `nfSkipFieldChecking`
* fixes #21023; Segfault when mixing seqs, orc, variants and futures (#21497)ringabout2023-03-101-18/+43
| | | | | | | | | * fixes #21023; Segfault when mixing seqs, orc, variants and futures * fixes none of the branches were explicitly selected * add one more test * one more test
* fixes #21260; add check for illegal recursion for defaults (#21270)ringabout2023-01-181-6/+9
| | | | | * fixes #21260; add check for illegal recursion for defaults * fixes differently
* fixes #20856; store defaults directly (#20859)ringabout2022-11-171-3/+3
| | | | | | | | | | | * fixes #20856; store defaults directly * fixes * fixes * check * fixes
* fixes object default fields bugs and add tests (#20839)ringabout2022-11-151-1/+6
| | | | | | | | | | | * 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 #20740; fixes pre-existing field visibility issues and removes ↵ringabout2022-11-031-6/+2
| | | | | `efSkipFieldVisibilityCheck` (#20741) fixes #20740 pre-existing field visibility and refactoring
* fixes #20681; add efSkipFieldVisibilityCheck to skip check (#20639)ringabout2022-10-281-2/+6
| | | | | | | | | | | | | | | | | * 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>
* add default field support for object in ARC/ORC (#20480)ringabout2022-10-041-36/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Improve error message when instantiating generics with object constructor ↵Bung2022-09-211-2/+6
| | | | | | | | | | | | | | | (#20358) * Improve error message when instantiating generics with object constructor * follow suggestion * Update compiler/semobjconstr.nim Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com> * Update tests/errmsgs/t19882_2.nim Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
* top-down type inference, implements rfc 149 (#20091)metagn2022-08-241-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* misc bugfixes [backport:1.2] (#19203)Andreas Rumpf2021-12-041-3/+3
|
* [FIX] Do not break formatted string line (#19085) [backport]haxscramper2021-11-021-2/+1
| | | | | Otherwise, compiler produces broken error message - `$1` is not interpolated `Error: The $1 type doesn't have a default value. The following fields must be initialized: importGraph.`
* fixes 'lent T' inside object constructor [backport] (#18911)Andreas Rumpf2021-09-271-1/+1
| | | | | * fixes 'lent T' inside object constructor [backport] * progress
* implements https://github.com/nim-lang/RFCs/issues/407 (#18793)Andreas Rumpf2021-09-031-14/+17
|
* refactoring: removed dead code (#18567)Andreas Rumpf2021-07-241-3/+2
|
* more informative error msg for undeclared field (`A(badfield: 1)` and ↵Timothee Cour2021-05-161-1/+2
| | | | `a.badfield = expr`) (#17777)
* improve errmsg refs #17793 object ctor with generics (#17806)Timothee Cour2021-04-211-1/+4
|
* fix `hintMsgOrigin` regression + simplify msgs code (#17805)Timothee Cour2021-04-211-7/+6
|
* Introduce localErrorNode (#17785)Clyybber2021-04-191-4/+2
|
* fixes #17437 - crash where error reporting > 1 (#17547)Saem Ghani2021-03-291-4/+12
| | | | | | | | | | | * fixes #17437 * Fix bug reference comment Co-authored-by: Timothee Cour <timothee.cour2@gmail.com> * [skip ci] describe why we have hasError Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
* Nil type check implementation (#15287)Alexander Ivanov2020-12-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Nil checking * Enable current older not nil checking again, run new checking only under flag, skip our test * Enable tests, work on try/except and bugs, fix notnil tests * Enable strictNotNil tests (currently with lowercase category) and add some expected output * Work on try/except/finally: still some things unclear and a lot of code can raise out of try * Fix the notnil build by going back to the old version of a test which I shouldn't have changed * Fix test : use action compile * Work on mutation and aliasing: not finished * Render var parititions graph, try to understand it, fix a nilcheck if bug * Rebase, progress on working with partitions * Improve time logic * Fix some bugs, use graph indices instead of symbol in nil map * Fix bugs, test simpler ident aliasing for now, support two mutation levels * Support ContentMutation and ReAssignment: for now just detect possible re assignment for var parameters of calls * Enable several simple passing tests * Cleanup a bit, fix condition/branch infix-related bug * Remove some files, address some comments by Araq * Use internalError and no quit for now * Separate tests with expected warnings and with expected ok, fix a bug with if with a single branch related to copyMap * Fix new data structures, bugs: make tests pass, disable some for now * Work on fixing errors with non-sym nodes, aliasing: tests fail * Work on alias support: simple set-based logic, todo more tests and ref sets? * Use ref sets: TODO can we think of handle seq-s similar to varpartitions' Araq ones * Handle defers in one place, stop raising in reverse to make an async test compile with strictNotNil, add a commented out test * Dot expressions: call/reassignment. Other refactorings and distinct, SeqOfDistinct support. Checkout an older varpartitions * Work on field tracking * Backup : trying to fix bugs when running some stdlib stuff for running an async test * Start a section about strict not nil checking in experimental manual * Fix experimental strict not nil manual section and move it to another file based on Araq feedback * Fix unstructured flow and double warning problems, fix manual, cleanup * Fix if/elif/else : take in account structure according to Araq feedback * Refactor a bit * Work on bracket expr support, re-enable tests, clarify in manual/tests/implementation static index support for now * Work on compiling stdlib and compiler with strictNotNil * Small fixes to the manual for strictNotNil * Fix idgen for strict check nil rebase * Enable some simple tests, remove old stuff, comment out code/print * Copy the original varpartitions source instead of my changes * Remove some files
* Make `{.requiresInit.}` to work for distinct types (#15869)Ivan Bobev2020-11-061-7/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make `requiresInit` pragma to work for distinct types in addition to objects. Tagging of distinct types with `requiresInit` pragma was already supported, but its impact wasn't applied. Now its behavior when applied on distinct types is as follows. Given the following distinct type definitions: ```nim type DistinctObject {.requiresInit, borrow: `.`.} = distinct MyObject DistinctString {.requiresInit.} = distinct string ``` The following code blocks will fail to compile: ```nim var foo: DistinctFoo foo.x = "test" doAssert foo.x == "test" ``` ```nim var s: DistinctString s = "test" doAssert s == "test" ``` But these ones will compile successfully: ```nim let foo = DistinctFoo(Foo(x: "test")) doAssert foo.x == "test" ``` ```nim let s = "test" doAssert s == "test" ```
* Big compiler Cleanup (#14777)Clyybber2020-08-281-2/+1
|
* fixes #15111 (#15136)Andreas Rumpf2020-08-011-19/+19
|
* init checks and 'out' parameters (#14521)Andreas Rumpf2020-06-231-1/+1
| | | | | | | | | | | * I don't care about observable stores * enforce explicit initializations * cleaner code for the stdlib * stdlib: use explicit initializations * make tests green * algorithm.nim: set result explicitly * remove out parameters and bring the PR into a mergable state * updated the changelog
* Fix tests/types/tparameterizedparent0Zahary Karadjov2020-04-011-1/+1
|
* Turn some of the errors back into warningsZahary Karadjov2020-04-011-0/+5
|
* Replace tfHasRequiresInit with a more accurate mechanismZahary Karadjov2020-04-011-22/+39
| | | | | | | | | The new mechanism can deal with more complex scenarios such as not nil field appearing in a non-default case object branch or a field within a generic object that may depend on a when branch. The commit also plugs another hole: the user is no longer able to create illegal default values through seq.setLen(N).
* More precise error messages for uninitialized fields in the presence of ↵Zahary Karadjov2020-04-011-35/+25
| | | | inheritance
* Turn the warning for uninitialized (result) variables into errorsZahary Karadjov2020-04-011-2/+3
|
* Plug another hole: default(T) forbidden for objects requiring initializationZahary Karadjov2020-04-011-0/+18
|
* Don't allow 'var x: T' for objects that require initializationZahary Karadjov2020-04-011-36/+32
|
* More sophistication; Allow requiresInit to be specified per-fieldZahary Karadjov2020-04-011-11/+21
|
* First steps, the compiler can boot with enforced requiresInitZahary Karadjov2020-04-011-9/+4
|
* ARC: optimize complete object constructors to use nimNewObjUninitAraq2020-01-261-0/+3
|
* Better case coverage error message for alias and range enum (#12913)Jasper Jenkins2019-12-181-47/+9
|
* Cosmetic compiler cleanup (#12718)Clyybber2019-11-281-26/+26
| | | | | | | | | | | | | | | | | | * Cleanup compiler code base * Unify add calls * Unify len invocations * Unify range operators * Fix oversight * Remove {.procvar.} pragma * initCandidate -> newCandidate where reasonable * Unify safeLen calls