Commit Graph

7277 Commits

Author SHA1 Message Date
Bung
cf12d6fcde fix #6637 array index type depends generic (#20673)
(cherry picked from commit aa6f9d490f)
2023-04-25 16:27:30 +02:00
ringabout
26e52d7c5d fixes #19201; fixes sink causes crash in VM (#20658)
(cherry picked from commit 4b377b07fc)
2023-04-25 16:27:30 +02:00
Bung
628c9c3c7f fix #12094 Use of _ (as var placeholder) inside a template causes XDe… (#20635)
fix #12094 Use of _ (as var placeholder) inside a template causes XDeclaredButNotUsed

(cherry picked from commit 4728c52c78)
2023-04-25 16:27:30 +02:00
Jason Beetham
32171fc66d Unpack mSlice tupleconstr for static openarrays (#20615)
(cherry picked from commit da0a2fdca2)
2023-04-25 16:27:29 +02:00
Bung
b220294f13 fix #20152 Illegal capture of closure iterator, when should be legal (#20607)
(cherry picked from commit 66cbcaab84)
2023-04-25 16:27:29 +02:00
Bung
6274bc35dd fix #19426 compile error using when/elif/else and typedesc in template (#20550)
(cherry picked from commit 04c48e3c5b)
2023-04-25 16:27:29 +02:00
Can Lehmann
a76f36b4e5 Fix #12517 Allow single branch when nimvm statements (#20577)
Allow single branch when statements

(cherry picked from commit 2102e3b02f)
2023-04-25 16:27:29 +02:00
Bung
425f828178 fix #19700 Crash when passing a template to a generic functio… (#20567)
fix nim-lang#19700 Crash when passing a template to a generic function expecting a procedure

(cherry picked from commit 0510a2be0d)
2023-04-25 15:34:47 +02:00
Bung
f2b52ec432 fix #7446 Generics: type mismatch 'SomeunsignedInt or Natural' (#20522)
* fix #7446 Generics: type mismatch 'SomeunsignedInt or Natural'

* try fix

(cherry picked from commit 083ea8f10c)
2023-04-25 15:34:47 +02:00
Bung
01d27ef1db fix #18886 crash on ambiguous proc cast (#20472)
* fix #18886 crash on ambiguous proc cast

* follow suggestion

(cherry picked from commit db3d2971cf)
2023-04-25 15:34:47 +02:00
Bung
0cf39669df Fix #19224 For loops over a hardcoded empty array crash the compiler (#20476)
* Fix #11684 For loops over a hardcoded empty array crash the compiler

* Update t19224.nim

(cherry picked from commit 567c3f055d)
2023-04-25 15:34:46 +02:00
Tomohiro
512aef60ae Use vccexe when generating static lib with vcc (#19843)
(cherry picked from commit 92a0f191bf)
2023-04-25 15:34:46 +02:00
Bung
0dc51dfe47 Improve error message when instantiating generics with object constructor (#20358)
* Improve error message when instantiating generics with object constructor

* follow suggestion

* Update compiler/semobjconstr.nim

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>

* Update tests/errmsgs/t19882_2.nim

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
(cherry picked from commit 2afce84616)
2023-04-24 22:09:34 +02:00
Bung
09be80c857 report expression has no type other than has to be used (or discarded… (#20392)
report expression has no type other than has to be used (or discarded) when typ is tyNone in discardCheck

(cherry picked from commit 08c02f0236)
2023-04-24 22:09:22 +02:00
Bung
82af5c7f6d fix #19882 Improve error message when instantiating generics that lac… (#20356)
* fix #19882 Improve error message when instantiating generics that lack a type

* Update tests/errmsgs/t19882.nim

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
(cherry picked from commit a302b26e0e)
2023-04-24 22:09:13 +02:00
Tomohiro
892b1f7583 Fix #16937; --clib option pass library name to backend C compiler correctly (#19754)
* Fix 16937: Make --clib option works

* Make tests/compiler/tcmdlineclib.nim works from any current dir

* Try to fix link error on macosx

* Add a comment to tests/compiler/tcmdlineclib.nims

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
(cherry picked from commit 2a34d143ac)
2023-04-24 22:09:07 +02:00
ringabout
7acdacb253 fixes #18983 #5282 #13008; recursive types casue infinite type (#20172)
* fixes #18983 #5282 #13008; recursive types casue infinite type

* re

* add testcases

(cherry picked from commit a895bbf714)
2023-04-24 22:08:53 +02:00
ringabout
b92336ab33 fixes #20149; fixes #16762; hintAsError and warningAsError now ignore foreign packages (#20151)
* fixes #20149;  hintAsError/warningAsError ignores foreign packages

* add changelog

* fixes the test

* remove

* fixes tests again

* fix

* I'm careless

Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
(cherry picked from commit 641381e3d4)
2023-04-24 22:08:02 +02:00
konsumlamm
f3300c1a9c Warn when casting to a larger type (#20103)
* Warn when casting to a larger type

* Revert change to error message to fix CI

(cherry picked from commit 528b6d1c3f)
2023-04-24 22:06:16 +02:00
Yuriy Glukhov
42020a2331 Fixed noinit pragma for closure variables (#20101)
(cherry picked from commit 424e87fd09)
2023-04-24 22:05:07 +02:00
metagn
e494f1b21e fix #20002 (#20004)
While this fix seems innocent,
this unlocks the hidden behavior of
method calls not being able to call
gensym'ed routines inside templates.

(cherry picked from commit f35c9cf73d)
2023-04-24 22:02:43 +02:00
Tanguy
ab1717984d Allow recursive closure iterators (#19939)
(cherry picked from commit ce4078acd4)
2023-04-24 22:01:28 +02:00
flywind
fbaeea8adf ref #19830; multiple definition of in Nim generated static libraries (#19934)
* ref #19830; multiple definition of in Nim generated static libraries

* fix compile errors

(cherry picked from commit 0189122d4f)
2023-04-24 21:58:49 +02:00
Tanguy
67b94a96f7 Better range error messages (#19867)
* Better range error messages

* Revert to old behavior for arrays

* Small corrections

(cherry picked from commit d33e112766)
2023-04-24 21:58:22 +02:00
Andreas Rumpf
9622c56f37 give a better error message for some template expansions (#19871)
(cherry picked from commit 25d89269eb)
2023-04-24 21:57:47 +02:00
quantimnot
1af76bc5a2 Stop type aliases from inheriting sfUsed (#19861)
Fixes #18201

Co-authored-by: quantimnot <quantimnot@users.noreply.github.com>
(cherry picked from commit f7a13f62d6)
2023-04-24 17:35:02 +02:00
Andreas Rumpf
3a685e863e fixes #14318 (#14335)
(cherry picked from commit 7d32425a57)
2023-04-24 17:34:28 +02:00
flywind
2dbceb319c remove tmpFramePtr when optStackTrace is absent (#19649)
(cherry picked from commit 84ac003519)
2023-04-24 17:34:18 +02:00
Andreas Rumpf
b13dba2c19 fixes #19603; some pragmas were really only supported as top level statements. Now this is enforced properly. (#19646)
(cherry picked from commit 51df9ff1c7)
2023-04-24 17:34:11 +02:00
flywind
31f7b17dd0 remove unnecessary framePtr code (#19645)
(cherry picked from commit afbcba909b)
2023-04-24 17:33:59 +02:00
Clyybber
ea69f04cc7 compiler: Handle nkCheckedFieldExpr better in dfa (#19616)
Simply recurse into their first child, which is always
a nkDotExpr instead of treating them seperately.
This fixes the rhs sym of a nkCheckedFieldExpr being
checked twice in aliases. This double checking didn't
cause any issues, but was unintentional and redundant.

(cherry picked from commit 3e83d73f27)
2023-04-24 17:33:53 +02:00
Jason Beetham
da325b0822 No longer segfault when using a typeclass with a self referencing type (#19467)
(cherry picked from commit 1830a3b505)
2023-04-24 17:33:13 +02:00
metagn
fe5edb7ab0 Don't reject types directly on AST (#19407)
Instead of rejecting type expressions based on node kind,
evaluate the expression as a type.
This is already the behavior for call results, and it has its own error
for non-types, which is the same error you would normally get
with 2 words swapped.

(cherry picked from commit 08261cb9e3)
2023-04-24 17:31:41 +02:00
Jason Beetham
de6d7dcca9 Fixed concept constraints for static types (#19391)
(cherry picked from commit 7bdfeb7819)
2023-04-24 17:31:34 +02:00
Jason Beetham
9e3762b6da Generic parameters now can constrain statics in type definitions (#19362)
* Parameters now can constrain static in type definitions

resolved regression with generic procedures

* Update compiler/sigmatch.nim

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
(cherry picked from commit a93f6e7acc)
2023-04-24 17:31:27 +02:00
hlaaftana
4857d9204e treat do with pragmas but no parens as proc (#19191)
fixes #19188

(cherry picked from commit 1ef945668d)
2023-04-24 17:28:15 +02:00
hlaaftana
c5df4ed62a fix #12274 (#19180)
(cherry picked from commit 2859069dbe)
2023-04-24 17:26:18 +02:00
Jason Beetham
48936ab1c0 Fix VM's sametype impl to work for generics/typedescs (#19073)
* Fix vm's sametype implementation to properly handle generics and typedescs

* actually fixed sametype + have test

* added comments and removed unsafe code

(cherry picked from commit cc984217a9)
2023-04-24 17:25:37 +02:00
Jason Beetham
b21f81dade Fixed distinct composite type class proc borrowing (#18904)
* Fixed composite type class proc borrowing

* Moved borrow search into transf

* added borrow check to symbol flag

(cherry picked from commit 8d5a275189)
2023-04-24 17:22:12 +02:00
Jason Beetham
5bb626d4b1 Fixed generic distinct conversions for 'var' (#18837)
* SameTypeAux now properly traverses generic distincts

* Smarter traversal of distincts

* Removed redundant check

* Fixed nkConv for jsgen

* Added test for non distinct nkConv

* using skiptypes for distinct now

* Fixed genaddr for nkconv

(cherry picked from commit 83a2515af7)
2023-04-24 17:22:05 +02:00
flywind
2f247ed1a7 remove exception (#18906)
(cherry picked from commit 4d8108046b)
2023-04-24 17:21:46 +02:00
Matt Haggard
bce9a9daed Fix long link commands on macOS (v1.6) (#21381)
Handle long link commands on macOS with a script, since ar does not support response files

Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
2023-04-23 19:28:54 +08:00
Bung
6007b12b30 fix #20997 calling system.card[T](x: set[T]) with T of int8 or uint8 … (#21010)
* fix #20997 calling system.card[T](x: set[T]) with T of int8 or uint8 uses mismatched C array sizes
* fullfil set variant

(cherry picked from commit 0b319fee3d)
2023-04-19 12:18:29 +02:00
tersec
30737676de remove seq[T] setLen undefined behavior (#21582)
remove seq[T] setLen UB

(cherry picked from commit 51ced0d684)
2023-04-05 13:28:47 +02:00
ringabout
48d18df69c fixes #21496; Ambiguous calls compiles when module name are equal (#21500)
* fixes #21496; Ambiguous calls compiles when module name are equal

* add a test case

(cherry picked from commit ffadc75afe)
2023-04-05 08:08:24 +02:00
ringabout
79b5f8c4e2 fixes #21306; fixes #20485; don't transform yields in the var section when introducing new local vars [backport: 1.6] (#21489)
* fixes #21306;  don't transform yields in the var section when introducing new local vars

* adds `inVarSection` so the var section in the var section is freshed

* use `isIntroducingNewLocalVars` to avoid yield transformations in var sections

* fixes comments

(cherry picked from commit f2dad94902)
2023-03-23 16:33:30 +01:00
Joey
43fa8663f7 Add line directives for C code variables (#21466) [backport:1.6] (#21518)
* Add line directives for C code variables

* Refactor genCLineDir to only use toFullPath if necessary

Signed-off-by: Joey Yakimowich-Payne <jyapayne@pm.me>
2023-03-17 17:04:11 +01:00
ringabout
19dd56f018 fixes #20139; hash types based on its path relative to its package path (#21274) [backport:1.6]
* fixes #20139; hash types based on its path relative its project

* add a test case

* fixes procs

* better implementation and test case

---------

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
(cherry picked from commit 38d299dfc0)
2023-03-09 18:32:51 +01:00
Andreas Rumpf
1cdce314a7 fixes #20422; emit nimPrepareStrMutationV2 for toOpenArray to keep th… (#21459)
fixes #20422; emit nimPrepareStrMutationV2 for toOpenArray to keep the abstraction of mutable strings which have immutable string literals

(cherry picked from commit 50baf21eac)
2023-03-02 10:29:24 +01:00
ringabout
60350eca1a fixes #1027; disallow templates to use ambiguous identifiers (#21405)
* Add `nkFastAsgn` into `semExpr` (#20939)

* Add nkFastAsgn into case statement

* Add test case

* fixes #1027; disallow templates to use ambiguous identifiers (#20631)

* test qualifiedLookUp in templates

* check later

* add testcase

* add 4errormsg

* Update tests/template/m1027a.nim

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>

* Update tests/template/m1027b.nim

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>

---------

Co-authored-by: Jake Leahy <jake@leahy.dev>
Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
2023-02-20 23:50:53 +08:00