summary refs log tree commit diff stats
path: root/compiler/semtypinst.nim
Commit message (Collapse)AuthorAgeFilesLines
* IC: progress and refactorings (#22961)Andreas Rumpf2023-11-201-2/+2
|
* Fix #17509: Continue instead of return with unfinished generics (#22563)SirOlaf2023-09-071-1/+2
| | | | | | | | | | | | | | | | | | | Close #17509 Current knowledge: - delaying cache fixes the issue - changing return of `if inst.len < key.len:` in `searchInstTypes` to `continue` fixes the issue. With return the broken types are also cached over and over Related issues are completely unaffected as of now, so there must be something deeper. I am also still trying to find the true cause, so feel free to ignore for now --------- Co-authored-by: SirOlaf <>
* minor refactoring, move some sym/type construction to semdata (#22654)metagn2023-09-071-2/+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`.
* fully revert generic inst sym change, test #22646 (#22653)metagn2023-09-061-11/+0
| | | | | | | reverts #22642, reopens #22639, closes #22646, refs #22650, refs https://github.com/alaviss/union/issues/51, refs #22652 The fallout is too much from #22642, we can come back to it if we can account for all the affected code.
* fix sym of created generic instantiation type (#22642)metagn2023-09-051-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fixes #22639 A `tyGenericInst` has its last son as the instantiated body of the original generic type. However this type keeps its original `sym` field from the original generic types, which means the sym's type is uninstantiated. This causes problems in the implementation of `getType`, where it uses the `sym` fields of types to represent them in AST, the relevant example for the issue being [here](https://github.com/nim-lang/Nim/blob/d13aab50cf465a7f2edf9c37a4fa30e128892e72/compiler/vmdeps.nim#L191) called from [here](https://github.com/nim-lang/Nim/blob/d13aab50cf465a7f2edf9c37a4fa30e128892e72/compiler/vmdeps.nim#L143). To fix this, create a new symbol from the original symbol for the instantiated body during the creation of `tyGenericInst`s with the appropriate type. Normally `replaceTypeVarsS` would be used for this, but here it seems to cause some recursion issue (immediately gives an error like "cannot instantiate HSlice[T, U]"), so we directly set the symbol's type to the instantiated type. Avoiding recursion means we also cannot use `replaceTypeVarsN` for the symbol AST, and the symbol not having any AST crashes the implementation of `getType` again [here](https://github.com/nim-lang/Nim/blob/d13aab50cf465a7f2edf9c37a4fa30e128892e72/compiler/vmdeps.nim#L167), so the symbol AST is set to the original generic type AST for now which is what it was before anyway. Not sure about this because not sure why the recursion issue is happening, putting it at the end of the proc doesn't help either. Also not sure if the `cl.owner != nil and s.owner != cl.owner` condition from `replaceTypeVarsS` is relevant here. This might also break some code if it depended on the original generic type symbol being given.
* When in object handles procedure call again, fixes #22474 (#22480)Jason Beetham2023-08-151-1/+1
| | | Ping @narimiran please backport to the 2.0 line.
* unpublic the sons field of PType; the precursor to PType refactorings (#22446)ringabout2023-08-111-6/+4
| | | | | | | | | | | * unpublic the sons field of PType * tiny fixes * fixes an omittance * fixes IC * fixes
* refactor `result = default(...)` into object construction (#22455)ringabout2023-08-111-10/+4
|
* `initNodeTable` and friends now return (#22444)ringabout2023-08-111-3/+3
|
* fix #18823 Passing Natural to bitops.BitsRange[T] parameter in generi… ↵Bung2023-08-081-6/+7
| | | | | (#20683) * fix #18823 Passing Natural to bitops.BitsRange[T] parameter in generic proc is compile error
* use strictdefs for compiler (#22365)ringabout2023-08-061-0/+3
| | | | | | | | | | | | | | | * wip; use strictdefs for compiler * checkpoint * complete the chores * more fixes * first phase cleanup * Update compiler/bitsets.nim * cleanup
* fix calls in generic bodies, delay typecheck when no overloads match (#22029)metagn2023-06-131-22/+24
| | | | | | | | | | | | | | | | | | | | | | | * sacrifice "tgenericshardcases" for working statics * legacy switch for CI, maybe experimental later * convert to experimental * apparently untyped needs the experimental switch * try special case call semcheck * try fix * fix compilation * final cleanup, not experimental, make `when` work * remove last needed use of untyped * fix unused warning in test * remove untyped feature
* refactoring in preparation for better, simpler name mangling that wor… ↵Andreas Rumpf2023-04-241-1/+1
| | | | | | | | | | | (#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
* Fix segfault caused by ensuring valueless statics are not evaluated (#21577)Jason Beetham2023-03-291-1/+1
|
* Made generic type classes work with types using static parameters (#21528)Jason Beetham2023-03-171-4/+23
|
* Fix #20416. Enable the recursion limit for ref/ptr types. (#21092)Aditya Siram2022-12-131-4/+14
|
* Revert "fixes #20883; Unspecified generic on default value segfaults the ↵ringabout2022-12-061-5/+1
| | | | | | | compiler" (#21028) Revert "fixes #20883; Unspecified generic on default value segfaults the compiler (#20917)" This reverts commit 10b6e4f5b4a119a8fa42f82a24ae7e4b08b2c103.
* fixes #20883; Unspecified generic on default value segfaults the compiler ↵ringabout2022-12-011-1/+5
| | | | | (#20917) test CI
* Fixes #20348; only respect the recursion limit if the symbol's generic type ↵Aditya Siram2022-09-221-11/+14
| | | | | has been generated by the compiler (#20377) Fixes #20348
* move assertions out of system (#19599)flywind2022-03-231-0/+3
|
* test whether it is unnecessary (#18893)flywind2021-10-141-1/+1
|
* Alternative to #18928 (#18931)Jason Beetham2021-09-301-6/+6
| | | | | * fixed #18841 * Added test
* semtypinst: don't wrap type nodes from expressions in static[T] (#18860)alaviss2021-09-171-1/+1
|
* Fixed #18838 (#18841) [backport]Jason Beetham2021-09-131-1/+5
|
* Fix recursive generic typed defs (#18809)Jason Beetham2021-09-061-1/+1
|
* fixes #16246 (#18800)Andreas Rumpf2021-09-041-1/+1
|
* ORC: improvements (#17993)Andreas Rumpf2021-05-121-1/+1
| | | | * ORC: improvements * ORC: fix .acyclic annotation for ref objects
* new-style concepts implementation, WIP (#15251)Andreas Rumpf2021-02-241-1/+3
| | | | | | | | | | | | | * 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)
* fixed dot operator recursive loop & macro suggest (#16922)Saem Ghani2021-02-151-0/+2
| | | | | | | | | | | | | | | | | | * basic stability improvements; refs nimsuggest * fixed dot operator recursive loop & macro suggest * hacky fix for run away dot operator sem check Committing this mostly to make the issue more clear. Perhaps get better feedback. * semExprWithType seems like a better place to check * fixed error messages const case expressions * Clean-up test * stopped the dot operator madness No longer get infinite recursion when seming broken code with a dot operator macro like in jsffi. Co-authored-by: Araq <rumpf_a@web.de>
* IC: final implementation steps (#16801)Andreas Rumpf2021-01-251-4/+4
| | | | | | | | * removed dead code * we need even more laziness for the generic caches * make it bootstrap on older Nims * wrote more deserialization code * IC: replay required methods information
* IC: next steps (#16729)Andreas Rumpf2021-01-231-19/+14
| | | | | | | | | | | * 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
* IC: next steps (#16705)Andreas Rumpf2021-01-141-18/+0
| | | | | | | | | | | * code cleanups * refactorings for IC * more refactorings for IC * IC: attach the 'nil' type to its module * IC: refactorings and improvements * IC: progress * IC: more serialization fixes * IC: embarrassing omission * code cleanups
* big steps torwards an efficient, simple IC implementation (#16543)Andreas Rumpf2021-01-021-3/+3
| | | | | | | | | | | | | | | | | | | * reworked ID handling * the packed AST now has its own ID mechanism * basic serialization code works * extract rodfiles to its own module * rodfiles: store and compare configs * rodfiles: store dependencies * store config at the end * precise dependency tracking * dependency tracking for rodfiles * completed loading of PSym, PType, etc * removed dead code * bugfix: do not realloc seqs when taking addr into an element * make IC opt-in for now * makes tcompilerapi green again * final cleanups Co-authored-by: Andy Davidoff <github@andy.disruptek.com>
* explicit ID generation for easier IC (#15559)Andreas Rumpf2020-10-251-7/+12
| | | | | | | | | | | | | | | | | * refactoring: idents don't need inheritance * refactoring: adding an IdGenerator (part 1) * refactoring: adding an IdGenerator (part 2) * refactoring: adding an IdGenerator (part 3) * refactoring: adding an IdGenerator (part 4) * refactoring: adding an IdGenerator (part 5) * refactoring: adding an IdGenerator (part 5) * IdGenerator must be a ref type; hello world works again * make bootstrapping work again * progress: add back the 'exactReplica' ideas * added back the missing exactReplica hacks * make tcompilerapi work again * make important packages green * attempt to fix the build for 32 bit machines (probably need a better solution here)
* Expand hoisted default params in sem (#15270)Clyybber2020-09-051-1/+1
| | | | | | | | | * Expand hoisted default params in sem Introduce ast.newTree{I,IT} Add test for default params in procs * Cleanup * Simplify hoist transformation and expand test
* Big compiler Cleanup (#14777)Clyybber2020-08-281-2/+1
|
* fix #14698 nkRecWhen caused internalAssert in semConstructFields when ↵Timothee Cour2020-07-271-1/+4
| | | | | | | | | | | generic type not mentioned in fields (#14709) * fix #14698 nkRecWhen caused internalAssert in semConstructFields when generic type not mentioned in fields * address comment * Update compiler/semtypinst.nim Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* [cleanups] doassert => doAssert; mark deadcode (#14711)Timothee Cour2020-06-171-10/+12
|
* fixes #14315 (#14594)Andreas Rumpf2020-06-071-2/+1
|
* avoid unsafe Nim features in preparation for --gc:arc (#14431)Andreas Rumpf2020-05-221-12/+13
|
* Replace tfHasRequiresInit with a more accurate mechanismZahary Karadjov2020-04-011-0/+2
| | | | | | | | | 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).
* fixes #13646Araq2020-03-161-0/+3
|
* minor code style changesAraq2020-03-161-1/+1
|
* ARC related bugfixes and refactorings (#12781)Andreas Rumpf2019-12-051-1/+3
|
* Cosmetic compiler cleanup (#12718)Clyybber2019-11-281-75/+74
| | | | | | | | | | | | | | | | | | * 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
* fixes #12336 [backport]Andreas Rumpf2019-10-021-1/+1
|
* Fix spellings (#12277) [backport]Federico Ceratto2019-09-271-3/+3
|
* some gc:destructors progressAndreas Rumpf2019-09-161-14/+0
|
* Small ast.nim cleanup (#12156)Clyybber2019-09-091-14/+14
| | | | | * Remove sonsLen * Use Indexable
* fixes #7258 (#12054)Andreas Rumpf2019-08-261-1/+25
|