Commit Graph

50 Commits

Author SHA1 Message Date
Andreas Rumpf
23c117a950 misc bugfixes [backport:1.2] (#19203) 2021-12-04 07:42:34 +01:00
haxscramper
4c510d5577 [FIX] Do not break formatted string line (#19085) [backport]
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.`
2021-11-02 08:54:04 +01:00
Andreas Rumpf
576fece909 fixes 'lent T' inside object constructor [backport] (#18911)
* fixes 'lent T' inside object constructor [backport]

* progress
2021-09-27 22:23:31 +02:00
Andreas Rumpf
cddf8ec6f6 implements https://github.com/nim-lang/RFCs/issues/407 (#18793) 2021-09-03 21:52:24 +02:00
Andreas Rumpf
f4ff276a90 refactoring: removed dead code (#18567) 2021-07-24 00:30:02 +02:00
Timothee Cour
3619a5a2aa more informative error msg for undeclared field (A(badfield: 1) and a.badfield = expr) (#17777) 2021-05-16 10:03:22 -07:00
Timothee Cour
2951f89374 improve errmsg refs #17793 object ctor with generics (#17806) 2021-04-21 10:52:17 +02:00
Timothee Cour
8de053d870 fix hintMsgOrigin regression + simplify msgs code (#17805) 2021-04-21 07:00:45 +02:00
Clyybber
438afb4db9 Introduce localErrorNode (#17785) 2021-04-19 17:19:21 +02:00
Saem Ghani
c6dc9c0255 fixes #17437 - crash where error reporting > 1 (#17547)
* 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>
2021-03-29 12:48:00 +02:00
Alexander Ivanov
672dc5cd87 Nil type check implementation (#15287)
* 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
2020-12-29 10:31:11 +01:00
Ivan Bobev
3c85aa9e53 Make {.requiresInit.} to work for distinct types (#15869)
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"
  ```
2020-11-06 18:56:09 +00:00
Clyybber
13e659cfec Big compiler Cleanup (#14777) 2020-08-28 22:18:09 +02:00
Andreas Rumpf
4ab6887a67 fixes #15111 (#15136) 2020-08-01 07:39:00 +02:00
Andreas Rumpf
da29222f86 init checks and 'out' parameters (#14521)
* 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
2020-06-23 10:53:57 +02:00
Zahary Karadjov
66f18037b3 Fix tests/types/tparameterizedparent0 2020-04-01 19:38:44 +02:00
Zahary Karadjov
be95f8fdfa Turn some of the errors back into warnings 2020-04-01 19:38:44 +02:00
Zahary Karadjov
ce9a4ed124 Replace tfHasRequiresInit with a more accurate mechanism
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).
2020-04-01 19:38:44 +02:00
Zahary Karadjov
7b7e42be54 More precise error messages for uninitialized fields in the presence of inheritance 2020-04-01 19:38:44 +02:00
Zahary Karadjov
1b570f2b18 Turn the warning for uninitialized (result) variables into errors 2020-04-01 19:38:44 +02:00
Zahary Karadjov
8ae48292ff Plug another hole: default(T) forbidden for objects requiring initialization 2020-04-01 19:38:44 +02:00
Zahary Karadjov
05a0ec4adb Don't allow 'var x: T' for objects that require initialization 2020-04-01 19:38:44 +02:00
Zahary Karadjov
7652aede41 More sophistication; Allow requiresInit to be specified per-field 2020-04-01 19:38:44 +02:00
Zahary Karadjov
a8b6222c86 First steps, the compiler can boot with enforced requiresInit 2020-04-01 19:38:44 +02:00
Araq
a10cc18247 ARC: optimize complete object constructors to use nimNewObjUninit 2020-01-26 13:43:02 +01:00
Jasper Jenkins
3c38edf563 Better case coverage error message for alias and range enum (#12913) 2019-12-18 10:29:01 +01:00
Clyybber
7e747d11c6 Cosmetic compiler cleanup (#12718)
* 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
2019-11-28 17:13:04 +01:00
Araq
61ea85687c refactoring: --newruntime consists of 3 different switches 2019-10-20 08:11:07 +02:00
Federico Ceratto
39290cf88c Fix spellings (#12277) [backport] 2019-09-27 07:02:54 +02:00
Oscar Nihlgård
4264e9576d Consider range type of runtime discrim [feature] (#11432) 2019-08-20 17:39:49 +02:00
Arne Döring
afbcd1b330 int128 on firstOrd, lastOrd and lengthOrd (#11701)
* fixes #11847
2019-08-07 15:53:16 +02:00
Andreas Rumpf
045eeab6b4 fixes #11585 2019-07-03 15:38:24 +02:00
Araq
bd55c862a6 fixes #11617 2019-07-01 13:12:04 +02:00
Jasper Jenkins
fc4f0808c4 parameter runtime discriminators (#11397)
* allow param for runtime discriminator construction
2019-06-04 22:10:39 +02:00
Jasper Jenkins
1286ba3452 fix bool and range (#11336) 2019-05-27 07:59:22 +02:00
Jasper Jenkins
f774426095 Smarter variant object construction (#11273) 2019-05-26 21:22:02 +02:00
Andreas Rumpf
a6d49c3a81 special typing rules for owned pointers 2019-03-04 15:41:07 +01:00
Andreas Rumpf
dae5450947 WIP: disallow 'nil' for strings and seqs 2018-08-13 11:41:33 +02:00
Andreas Rumpf
40ec7be45c refactoring: remove idents.legacy global variable and pass the IdentCache around explicitly 2018-05-27 22:09:15 +02:00
Andreas Rumpf
050789a8f4 sem pass compiles again 2018-05-12 21:30:42 +02:00
Andreas Rumpf
ce859d8c16 more modules compile again 2018-05-12 16:35:59 +02:00
Araq
824092be31 fixes a regression about static object case variant checking 2018-04-06 13:01:24 +02:00
Araq
9de05ec3e0 further steps in implementing sink parameters; refs #7041 2018-03-30 02:32:13 +02:00
Andreas Rumpf
31263ef8f3 fixes #5450 2018-02-04 07:35:32 +01:00
Andreas Rumpf
e4081a7201 preparations for language extensions: 'sink' and 'lent' types 2018-01-07 23:09:26 +01:00
Araq
1bb086e7a8 fixes #5999 2017-12-14 20:55:02 +01:00
Andreas Rumpf
d52a1061b3 work in progress: new implementation for 'a[^1]' 2017-10-29 19:46:17 +01:00
Andreas Rumpf
70ea45cdba deprecated unary '<' 2017-10-29 08:37:13 +01:00
Daniil Yarancev
5c7ae14074 Fixes #5965 (#6237) 2017-08-14 17:43:39 +02:00
Zahary Karadjov
34c34cb49b move the object construction logic to a separate file 2017-04-06 00:46:18 +03:00