summary refs log tree commit diff stats
path: root/compiler/semstmts.nim
Commit message (Collapse)AuthorAgeFilesLines
* remove conditionals on nimHasUserErrors, nimNoNilSeqs2, nimNoNilSeqs (#16861)Timothee Cour2021-01-291-4/+1
| | | | | | | | | * cleanup docs for type(nil) | type(nil); simplify nimHasUserErrors * simplify nimNoNilSeqs2 * simplify nimNoNilSeqs * fixup
* IC: final implementation steps (#16801)Andreas Rumpf2021-01-251-2/+2
| | | | | | | | * 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-10/+13
| | | | | | | | | | | * 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-2/+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
* IC: next steps (#16550)Andreas Rumpf2021-01-071-6/+6
| | | | | | | | | | | | | | | | | | * cleanups * ast.nim: cleanups * IC: no more sym.tab field, stored externally in the module graph * nimble compiles again * rodfiles: store bitwidth of integers and the endianness in the cookie because we serialize 'int' directly * rodfiles: added compilerproc and export sections * rodfiles: added all the missing sections * rodfiles: track the missing information * IC: architecture for lazy loading of proc bodies * make tests green again * completed the lazy loading of proc bodies * symbol lookup integration, part 1 * symbol lookup integration, part 2 * symbol lookup integration, part 3 * make tcompilerapi work again * rodfiles: fixed config change handling
* big steps torwards an efficient, simple IC implementation (#16543)Andreas Rumpf2021-01-021-6/+7
| | | | | | | | | | | | | | | | | | | * 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>
* refactorings to prepare the compiler for IC (#15935)Andreas Rumpf2020-12-171-4/+6
| | | | | | | | | | | | | | * added ic specific Nim code; WIP * make the symbol import mechanism lazy; WIP * ensure that modules can be imported multiple times * ambiguity checking * handle converters and TR macros properly * make 'enum' test category green again * special logic for semi-pure enums * makes nimsuggest tests green again * fixes nimdata * makes nimpy green again * makes more important packages work
* fixes #16119 [backport:1.4] (#16149)Andreas Rumpf2020-11-261-3/+3
|
* More on #16110 (#16130)cooldome2020-11-261-2/+11
| | | | | | | | | | | * fix #16110 * refs #16110 * fix comment * Trigger build * use shallowCopy for efficiency
* fix #16110 (#16117)cooldome2020-11-241-1/+2
|
* Revert "fix #16110"Andrey R (cooldome)2020-11-241-2/+1
| | | | This reverts commit 2bab2a2cd8476423414819db3ad79309f6033e13.
* fix #16110Andrey R (cooldome)2020-11-241-1/+2
|
* fix #15972 (#15994)flywind2020-11-181-2/+2
| | | | | | | * fix #15972 * add testcase * more
* Correct all eggs (#15906)Miran2020-11-101-1/+1
| | | | * "eg" is a misspelled "egg", "e.g." is "exempli gratia" * Also, "ie" is "i.e.".
* Make `{.requiresInit.}` to work for distinct types (#15869)Ivan Bobev2020-11-061-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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" ```
* explicit ID generation for easier IC (#15559)Andreas Rumpf2020-10-251-22/+22
| | | | | | | | | | | | | | | | | * 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)
* renamed '=' to '=copy' [backport:1.2] (#15585)Andreas Rumpf2020-10-151-2/+2
| | | | | | | | | * Assign hook name changed to `=copy` * Adapt destructors.rst * [nobackport] Duplicate tests for =copy hook * Fix tests * added a changelog entry Co-authored-by: Clyybber <darkmine956@gmail.com>
* suggest: try to find the implementation of a symbol when def is used (#15555)alaviss2020-10-141-0/+1
| | | | | * suggest: try to find the implementation of a symbol when def is used * suggest: return all declarations of the symbol on `def`
* implements https://github.com/nim-lang/RFCs/issues/258 (#15503)Andreas Rumpf2020-10-061-1/+1
| | | | | | | | | * implements https://github.com/nim-lang/RFCs/issues/258 * don't be too strict with custom pragma blocks * cast pragmas: documentation * added most missing inference query procs to effecttraits.nim
* Fix #15389 (#15390)cooldome2020-09-241-17/+16
| | | | | | | | | * allow result symbol reuse * try different approach * Revert "try different approach" This reverts commit abcfb6b75983c2f798cc887342ff1a9ff10c0324.
* Fix forward declarations in shadow scope contexts (#15386)Clyybber2020-09-221-4/+5
| | | | | | | | | | | | | | | * Fix forward declarations in shadow scope contexts * Add testcase for #15385 * Less empty lines * Fix tests * Inline isShadowScope * Add original testcase (with reduced amount of iterations) * Add testcase without forward decl
* fixes #15360 [backport:1.2] (#15378)Andreas Rumpf2020-09-211-1/+1
|
* borrow checking (#15282)Andreas Rumpf2020-09-091-2/+2
| | | | | | | | | | | * refactoring: move procs to typeallowed.nim * frontend preparations for first class openArray support * prepare the code generator for first class openArray * code generation for first class openArray; WIP * code generation for open arrays, progress * added isViewType proc * preparations for borrow checking * added borrow checking to the front end
* "for-loop macros" are no longer an experimental feature (#15288)Miran2020-09-081-3/+2
|
* don't raise index defects on malformed ast (#15278)Andy Davidoff2020-09-071-3/+6
| | | | | * don't raise index defects on malformed ast * style
* Fix #5691 (#15158)Clyybber2020-08-271-1/+1
| | | | | | | | * Fix #5691 * Cleanup and thoughts * Use scope approach * Seperate defined/declared/declaredInScope magics * Fix declaredInScope * Update spec accordingly
* fixes a collect() bug reported on the forum (#15156) [backport:1.2]Andreas Rumpf2020-08-041-1/+1
|
* Fix forward declaration issues in template/macro context (#15091)Clyybber2020-07-291-2/+4
| | | | | | | | | | | | | | | | | | | | | | | * Fix forward declaration issues in template/macro context * Correct forward declaration resolving for overloads * Remove old dead code * WIP consistent gensym ids * Minimize diff * Remove obsoleted hack * Add templInstCounter to give unique IDs to template instantiations * Remove obsoleted code * Eh, init in myOpen, not myProcess... * Remove optNimV019 * Add testcase for #13484
* scoped memory management (#14790)Andreas Rumpf2020-07-041-2/+2
| | | | | | | * fixes the regressions * closes #13936 * scope based memory management implemented * enabled tcontrolflow.nim test case * final cleanups
* Clean out oldast (#14837)Juan Carlos2020-06-301-16/+12
| | | | * Clean out old Deprecated CLI switch * Update to remove --oldast CLI option
* Make unreachable code a warning instead of an error (#14816)Clyybber2020-06-291-4/+2
| | | | | | | * Make unreachable code a warning * Adapt test * Trigger CI
* init checks and 'out' parameters (#14521)Andreas Rumpf2020-06-231-14/+4
| | | | | | | | | | | * 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
* misc cleanups in compiler msgs: use toHumanStr, etc (#14677)Timothee Cour2020-06-151-2/+1
|
* disallow typedesc in arrays & move existing checks to `types.typeAllowedAux` ↵Neelesh Chandola2020-05-291-24/+21
| | | | | | (#13261) * disallow typedesc in arrays and move previous checks to types.typeAllowedAux
* Allow let to not have value when using importc (#14258)PMunch2020-05-121-2/+3
| | | | | | | | | | | | | | * Allow let to not have value when using importc This allows a let statement with the `{.importc.}` pragma to not be initialised with a value. This allows us to declare C constants as Nim lets without putting the value in the Nim code (which can lead to errors, and requires us to go looking for the value). Fixes #14253 * Proper fix and documentation + changelog entry * Improve testcase with one from timotheecour * Add test to verify it working with macros
* improve the 'has to be discarded' error messageAraq2020-05-021-2/+2
|
* Make unreachable else in case statements a warning instead of an error (#14190)Clyybber2020-05-021-1/+1
| | | | | * Fix #14019 by making trailing else a warning * Rename to UnreachableElse
* Make ./koch temp --gc:arc work (#14186)Clyybber2020-05-011-1/+1
|
* fixes #12741 (#14005)Andreas Rumpf2020-04-191-2/+2
| | | | * fixes #12741 * updated tests
* fix #13909 (#13914) [backport:1.2]cooldome2020-04-081-3/+8
| | | Co-authored-by: cooldome <ariabushenko@bk.ru>
* Replace tfHasRequiresInit with a more accurate mechanismZahary Karadjov2020-04-011-2/+4
| | | | | | | | | 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).
* Turn the warning for uninitialized (result) variables into errorsZahary Karadjov2020-04-011-3/+2
|
* Enable the requiresInit checks only for objectsZahary Karadjov2020-04-011-1/+1
|
* Plug another hole: default(T) forbidden for objects requiring initializationZahary Karadjov2020-04-011-1/+1
|
* Don't allow 'var x: T' for objects that require initializationZahary Karadjov2020-04-011-1/+5
|
* First steps, the compiler can boot with enforced requiresInitZahary Karadjov2020-04-011-1/+1
|
* DrNim (Nim compiler with Z3 integration) (#13743)Andreas Rumpf2020-03-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | * code cleanups and feature additions * added basic test and koch/CI integration * make it build on Unix * DrNim: now buildable on Unix, only takes 10 minutes, enjoy * added basic documentation for DrNim which can also be seen as the RFC we're following * drnim: change the build setup so that drnim.exe ends up in bin/ * makes simple floating point ranges work * added basic float range check * drnim: teach Z3 about Nim's range types plus code refactoring * drnim: make unsigned numbers work * added and fixed index checking under setLen * first implementation of .ensures, .invariant and .assume (.requires still missing and so is proc type compatibility checking * drnim: .requires checking implemented * drnim: implemented .ensures properly * more impressive test involving min() * drnim: check for proc type compatibility and base method compatibility wrt .requires and .ensures * testament: support for 'pattern <directory> * koch: uses new <directory> feature of testament * drnim: added tiny musings about 'old' * Make testament work with old SSL versions * koch: add support for 'koch drnim -d:release' * drnim: preparations for the param.old notation
* macros for proc types, macros for types (#13778)Andreas Rumpf2020-03-311-57/+65
| | | | | | | | | * new minor feature: macros for proc types, to be documented * Finished the implementation and added tests * [skip ci] Describe the new custom pragmas in the manual and the changelog Co-authored-by: Zahary Karadjov <zahary@gmail.com>
* fixes #13763 (#13777)Andreas Rumpf2020-03-271-1/+3
|
* Fix typeSym.getImpl for ref types (#13752)zah2020-03-261-1/+1
| | | | | | | | | | | | | | | | | | | | | * Fix typeSym.getImpl for ref types * Fix a codegen issue affecting the test suite of nim-beacon-chain * Fix tests/stdlib/tjsonmacro To understand the fix better it may help to take a look at the history of the replaced code. The nil check that is removed in this commit was introduced in another fix that failed to identify the root cause of the issue - namely that we allow an object type to exist for which no ast is present: https://github.com/nim-lang/Nim/pull/9601/files The original intention of the code is more obvious here: https://github.com/nim-lang/Nim/pull/9538/files