summary refs log tree commit diff stats
path: root/compiler/semstmts.nim
Commit message (Collapse)AuthorAgeFilesLines
* 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
* fix #13737 (#13738)Timothee Cour2020-03-241-1/+2
|
* new syntax for lvalue references: `var b {.byaddr.} = expr` (#13508)Timothee Cour2020-03-231-0/+46
| | | | | | | | * new syntax for lvalue references: `var b {.byaddr.} = expr` * on type mismatch, `???(0, 0)` not shown anymore * * compiler now lowers `var a: {.foo.}: MyType = expr` to foo(a, MyType, expr) * new pragmas.byaddr defined in pure library code exploiting this lowering * skip `template foo() {.pragma.}`
* catchable defects (#13626)Andreas Rumpf2020-03-121-1/+1
| | | | | | | | | | * allow defects to be caught even for --exceptions:goto (WIP) * implemented the new --panics:on|off switch; refs https://github.com/nim-lang/RFCs/issues/180 * new implementation for integer overflow checking * produce a warning if a user-defined exception type inherits from Exception directly * applied Timothee's suggestions; improved the documentation and replace the term 'checked runtime check' by 'panic' * fixes #13627 * don't inherit from Exception directly
* fixes #5170 (#13589)Andreas Rumpf2020-03-051-0/+2
| | | | | | * fixes #5170 * make tests green
* sink parameter inference for types that have destructors (#13544)Andreas Rumpf2020-03-041-0/+2
| | | | | | | | | | | | | | * ensure capitalize doesn't take an inferred sink parameter * sink parameter inference: first version, for now disabled. Changed that sink parameters can be consumed multiple times in order to adhere to our spec. * sink inference can now be disabled with .nosinks; sometimes for proc type interop this is required * fixes yet another critical DFA bug * better implementation that also understands if expressions etc * document sink parameter inference and allow for global disabling
* EndsInNoReturn in expressions extension, fixes #13490 (#13520)cooldome2020-02-281-5/+2
| | | | * fix #13490
* fix #13255 (#13275) [backport]Arne Döring2020-02-091-2/+2
|
* make case-object transitions explicit, make unknownLineInfo a const, replace ↵Jasper Jenkins2020-01-171-9/+9
| | | | a few magic numbers with consts (#13170)
* fixes #13112 (#13127)Andreas Rumpf2020-01-131-0/+9
| | | | | | * improve line error information * fixes #13112
* fixes a bug that kept sugar.collect from working with for loop macros [backport]Araq2019-12-241-10/+11
|
* case coverage error message for `char` (#12948)Jasper Jenkins2019-12-221-1/+1
|
* Better case coverage error message for alias and range enum (#12913)Jasper Jenkins2019-12-181-3/+3
|
* ARC: cycle detector (#12823)Andreas Rumpf2019-12-171-34/+46
| | | | | | | | | | | | | * first implementation of the =trace and =dispose hooks for the cycle collector * a cycle collector for ARC: progress * manual: the .acyclic pragma is a thing once again * gcbench: adaptations for --gc:arc * enable valgrind tests for the strutils tests * testament: better valgrind support * ARC refactoring: growable jumpstacks * ARC cycle detector: non-recursive algorithm * moved and renamed core/ files back to system/ * refactoring: --gc:arc vs --gc:orc since 'orc' is even more experimental and we want to ship --gc:arc soonish