Commit Graph

773 Commits

Author SHA1 Message Date
Andreas Rumpf
a6d84179fc feature: the compiler can warn when you use the implicit 'result' variable (#17988) [backport:1.2]
* implements #17855

(cherry picked from commit 378ee7f888)
2021-05-14 13:14:52 +02:00
Andreas Rumpf
cf1ecee794 fixes #11225; generic sandwich problems; [backport:1.2] (#17255)
* fixes #11225; generic sandwich problems; [backport:1.2]
* progress
* delegating these symbols must be done via 'bind'

(cherry picked from commit 2f213db7ee)
2021-03-18 14:08:54 +01:00
Miran
04f810c2ec Correct all eggs (#15906)
* "eg" is a misspelled "egg", "e.g." is "exempli gratia"
* Also, "ie" is "i.e.".

(cherry picked from commit bbe49a14ae)
2020-11-16 06:54:45 +01:00
Andreas Rumpf
4058801607 spec for view types (#15424)
* spec for view types
* spec additions
* refactoring; there are two different kinds of views
* refactorings and spec additions
* enforce that view types are initialized
* enforce borrowing from the first formal parameter
* enforce lifetimes for borrowing of locals
* typo in the manual
* clarify in the implementation what a borrow operation really is
2020-09-29 23:42:38 +02:00
Andreas Rumpf
57b7841c18 better support for slices as views (#15414)
* moved view tests to tests/views
* refactoring
* more refactorings
* better support for system.toOpenArray for first class view types
2020-09-27 09:20:10 +02:00
cooldome
f21a49b2c4 Fix #15389 (#15390)
* allow result symbol reuse

* try different approach

* Revert "try different approach"

This reverts commit abcfb6b759.
2020-09-24 00:07:30 +01:00
Andreas Rumpf
10988d4840 borrow checking (#15282)
* 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
2020-09-09 07:32:03 +02:00
Clyybber
35ff17410f Expand hoisted default params in sem (#15270)
* 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
2020-09-05 22:01:47 +02:00
Clyybber
13e659cfec Big compiler Cleanup (#14777) 2020-08-28 22:18:09 +02:00
Clyybber
fb58066b61 Fix #5691 (#15158)
* Fix #5691
* Cleanup and thoughts
* Use scope approach
* Seperate defined/declared/declaredInScope magics
* Fix declaredInScope
* Update spec accordingly
2020-08-27 15:50:59 +02:00
Clyybber
2629d619a1 Fix forward declaration issues in template/macro context (#15091)
* 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
2020-07-29 16:17:20 +02:00
flywind
086efac49b fix #6608 (#14963)
* fix #6608
2020-07-14 09:22:48 +02:00
Clyybber
5bd2da3f64 Fix #14911 (#14922) [backport]
* Fix #14911

* Add testcase

* Fix test
2020-07-07 10:21:18 +02:00
Danil Yarantsev
80952cadaa Reject casts to builtin typeclasses (#14788)
* Closes #14231, closes #14452

* Merge test to tcast.nim
2020-06-24 22:32:01 +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
Timothee Cour
4301a3da9d * honor --errorMax even for tools (eg drnim, nim doc) (#14546)
* fix a bug that prevented nim doc compiler/nim on windows
2020-06-02 18:54:33 +02:00
Danil Yarantsev
00ec43305e Fix compiles for nimsuggest [backport] (#14527)
* Handle nimsuggest in tryExpr
* Added test
2020-06-01 15:06:45 +02:00
Andreas Rumpf
7ccc7d7e93 fixes #14498 [backport:1.2] (#14503) 2020-05-30 15:32:31 +02:00
Timothee Cour
fe7a2d60f9 make it easier to figure out how to debug issues (#14477) 2020-05-28 01:19:12 -07:00
Timothee Cour
9502e39b63 nim doc --backend:js, nim doc --doccmd:-d:foo, nim r --backend:js, --doccmd:skip + other improvements (#14278)
* `nim doc --backend:js|cpp...`
`nim doc --doccmd:'-d:foo --threads:on'`
`nim r --backend:cpp...` (implies --run --usenimcache)
* --usenimcache works with all targets
* --docCmd:skip now skips compiling snippets; 50X speedup for doc/manual.rst
2020-05-11 12:01:18 +02:00
Jasper Jenkins
ba0af0f827 allow generic typedesc field access (#12220)
Co-authored-by: Clyybber <darkmine956@gmail.com>
2020-04-20 15:36:57 +02:00
Andreas Rumpf
73eff1f457 fixes #12741 (#14005)
* fixes #12741
* updated tests
2020-04-19 11:59:01 +02:00
cooldome
8ba915e449 error msg for #13864 (#13962)
Co-authored-by: cooldome <ariabushenko@bk.ru>
2020-04-13 14:17:22 +02:00
Timothee Cour
814f150184 fix #13848: make var result work with nim cpp (#13959)
* fix #13848

* add exhaustive tests for var result
2020-04-13 14:16:06 +02:00
cooldome
b4e9f8e814 fix ICE in isUnresolvedSym (#13925)
Co-authored-by: cooldome <ariabushenko@bk.ru>
2020-04-08 13:16:25 +01: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
d374c6373b Fix tests/parallel/tguard2.nim 2020-04-01 19:38:44 +02:00
Zahary Karadjov
e63b673ce2 Fix https://github.com/nim-lang/Nim/issues/4907 2020-04-01 19:38:44 +02:00
Zahary Karadjov
4f3d309fb0 Perform nil checks during object construction and within compiles()
Close https://github.com/nim-lang/Nim/issues/6494
2020-04-01 19:38:44 +02:00
Zahary Karadjov
f3be5a716f not nil types are illegal to construct through default(T) 2020-04-01 19:38:44 +02:00
Zahary Karadjov
54f06427c8 Enable the requiresInit checks only for objects 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
Timothee Cour
19cab9fa51 stacktraces can now show custom runtime msgs per frame (#13351)
* stacktraces can now show custom runtime msgs
* improve tests/stdlib/tstackframes.nim
* fix test for --gc:arc
* test --stacktraceMsgs:on and --stacktraceMsgs:off
* --stacktracemsgs:off by default
2020-03-30 13:45:32 +02:00
cooldome
764a81ca25 Continue bool conversion fixing (#13751)
* continue fixing #13744

* improve style

* improve test

Co-authored-by: cooldome <ariabushenko@bk.ru>
2020-03-25 21:36:22 +01:00
Araq
12ab5059a0 make 'nim check' more robust for illdefined constants 2020-03-20 10:46:40 +01:00
Andreas Rumpf
5f6997794e fixes #13671 [backport] (#13678) 2020-03-18 10:37:36 +01:00
Araq
a102eb5ef6 fixes #13646 2020-03-16 14:55:58 +01:00
Timothee Cour
bd90199a2f fix #8312 --hints:off and --warnings:off now honored everywhere (#13489) 2020-02-26 10:26:47 +01:00
Timothee Cour
7939319379 fix is with generic types; fix genericHead(Foo[T]) (#13303)
* fix #9855, fix #9855, fix genericHead
* render TTypeKind via toHumanStr
2020-02-09 13:48:55 +01:00
Jasper Jenkins
796aafe7e0 make case-object transitions explicit, make unknownLineInfo a const, replace a few magic numbers with consts (#13170) 2020-01-17 10:34:31 +01:00
cooldome
649bf326bf fixes #12945 (#12959) 2019-12-24 20:34:14 +01:00
Andreas Rumpf
83a736a34a ARC: cycle detector (#12823)
* 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
2019-12-17 17:37:50 +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
Oscar Nihlgård
9ccfcf5dd2 Fix compiler crash caused by top level return (#12501) 2019-10-24 11:04:04 +02:00
Araq
61ea85687c refactoring: --newruntime consists of 3 different switches 2019-10-20 08:11:07 +02:00
Arne Döring
7cf3395d85 refactor illegal iterator assignment detection (#12212)
* refactor illegal iterator assignment detection

* delete crappy test
2019-10-11 08:43:58 +02:00
Federico Ceratto
39290cf88c Fix spellings (#12277) [backport] 2019-09-27 07:02:54 +02:00
cooldome
be82d11576 fixes #12224 (#12225)
* fixes #12224

* improve test
2019-09-21 06:45:27 +02:00
Araq
8b4c17a140 better implementation 2019-09-16 12:12:44 +02:00