Commit Graph

842 Commits

Author SHA1 Message Date
ringabout
21a26548a4 fixes #14255; Crash in compiler when using system.any by accident. (#21562)
fixes #14255; Crash in compiler when using system.any by accident.

(cherry picked from commit 55636a2913)
2023-04-26 15:09:47 +02:00
Bung
24e4099d36 fix #21109 (#21127)
(cherry picked from commit e278a781fc)
2023-04-26 11:00:48 +02:00
Bung
f0324e99da fix #20588 (#21104)
(cherry picked from commit 8054be6e52)
2023-04-26 10:57:45 +02:00
Bung
4ea0ce9149 fix #15836 proc arg return type auto unexpectly match proc with concr… (#21065)
* fix #15836 proc arg return type auto unexpectly match proc with concrete type

* fix #16244

* add test case for #12869

(cherry picked from commit 5917c2d5b7)
2023-04-26 10:53:43 +02:00
Bung
918a7d9f54 fix #16758 Nim crashes in fixAbstractType (#20855)
* fix #16758 Nim crashes in fixAbstractType

* Update compiler/semexprs.nim

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
(cherry picked from commit 1585bfec3b)
2023-04-26 10:53:28 +02:00
ringabout
71c5bdf6b3 fixes #21027; cast expressions need a type (#21029)
* fixes #21027; cast expressions need a type

* Apply suggestions from code review

Thanks to @beef331

(cherry picked from commit 1564ae650f)
2023-04-26 09:31:33 +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
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
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
Tanguy
ab1717984d Allow recursive closure iterators (#19939)
(cherry picked from commit ce4078acd4)
2023-04-24 22:01:28 +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
narimiran
afdbfd2c7e fix some merge conflict leftovers 2023-01-31 18:01:06 +01:00
Ivan Yonchovski
17d45dfd6a Implemented basic macro expand functionality (#20579)
* Implemented level based macro expand functionality

- it can handle single macro call or expand whole function/proc/etc and it

- In addition, I have altered the parser to provide the endInfo for the node.
The usefulness of the `endInfo` is not limited to the `expandMacro`
functionality but also it is useful for `ideOutline` functionality and I have
altered the ideOutline functionality to use `endInfo`. Note `endInfo` most of
the time is lost during the AST transformation thus in `nimsuggest.nim` I am
using freshly parsed tree to get the location information.

* Make sure we stop expanding correctly

* Test CI

* Fix tv3_outline.nim

(cherry picked from commit 7031ea65cd)
2023-01-31 10:23:52 +01:00
Jake Leahy
0cdbf5e04e Add nkFastAsgn into semExpr (#20939)
* Add nkFastAsgn into case statement

* Add test case

(cherry picked from commit d26b1232ee)
2023-01-20 08:35:30 +01:00
narimiran
7f90bcf5b4 and one more missed error 2022-11-30 19:11:44 +01:00
metagn
0683e8f747 fix bugs with dot & call operators [backport] (#20931)
* better error messages for dot operators [backport]

fixes #13063

* also fixes #7777

* fix #6981 and #9831 too

* fix

* minor improvement

* sus test fixes

* make test multiplatform lol

* fix nimsuggest test, extra improvements

(cherry picked from commit 555c5ed1a7)
2022-11-30 07:29:42 +01:00
quantimnot
c484943cab Change styleCheck to ignore foreign packages (#19822)
* Change `styleCheck` to ignore foreign packages

* Symbols from foreign packages are now ignored.
* Fixed `styleCheck` violations in `compiler` package.
* Added symbol ownership to custom annotation pragmas.
* Minor refactors to cleanup style check callsites.
* Minor internal documentation of reasons why a symbol isn't checked.

Style violations were fixed in the compiler after thet were exposed by
the changes. The compiler wouldn't compile otherwise.

Symbol ownership for custom pragma annotations is needed for checking
the annotation's style. A NPE was raised otherwise.

Fixes #10201
See also nim-lang/RFCs#456

* Fix a misunderstanding about excluding field style checks

I had refactored the callsites of `styleCheckUse` to apply the DRY
principle, but I misunderstood the field access handling in a template
as a general case. This corrects it.

* Fix some `styleCheck` violations in `compiler/evalffi`

The violations were exposed in CI when the compiler was built with
libffi.

* Removed some uneeded transitionary code

* Add changelog entry

Co-authored-by: quantimnot <quantimnot@users.noreply.github.com>
(cherry picked from commit 800cb006e7)
2022-08-02 16:00:11 +02:00
nc-x
4f392727c8 Fix fixAbstractType for user defined typeclasses, fixes #19730 & #18409 (#19732)
(cherry picked from commit 4680ab61c0)
2022-05-02 16:23:20 +02:00
Ivan Yonchovski
4bb2e9e921 Make sure that field usage preserves the original line info (#19751)
Currently `struct.field` will generate a node with `info` that points to the
symbol definition instead of having the actual node location.

(cherry picked from commit e4a2c2d474)
2022-05-02 16:23:07 +02:00
flywind
9035618347 fix stylecheck bug with nre (#19356)
* stylecheck usages part two: stdlib cleanup

typeinfo.nim: importCompilerProc => importcompilerproc

nre.nim: newLineFlags => newlineFlags

system.nim: JSRoot => JsRoot

ref #19319

* prefer importCompilerProc

* fix stylecheck error with asyncdispatch

it is a partial regression since #12842

* add tests

* don't use echo in tests

* fix stylecheck bug with nre

* Update compiler/linter.nim

* no need to check dotexpr again

* neither did let/var/const

(cherry picked from commit 00775f6880)
2022-04-08 11:24:55 +02:00
Jason Beetham
26ed4e5413 Fixed object field access of static objects in generics (#19283) [backport]
(cherry picked from commit fa96e56ad0)
2021-12-31 05:13:27 +01:00
林亦恩
e645be4d0c add ghci like type annotation buildEchoStmt (1049) (#18875)
* add ghci like type annotation buildEchoStmt (1049)

* Update compiler/semexprs.nim

* Update compiler/semexprs.nim

Co-authored-by: flywind <xzsflywind@gmail.com>

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Co-authored-by: flywind <xzsflywind@gmail.com>
2021-10-13 11:35:47 +02:00
flywind
677969f6ea alternative to #18918 (#18927)
* fix #16558

* add testcase
2021-09-30 16:57:06 +02:00
Andreas Rumpf
6163bdd279 closes #16132 [backport] (#18880)
* closes #16132 [backport]

* fixes #16132 [backport]
2021-09-22 15:07:36 +02:00
Andreas Rumpf
0ad601d3c1 fixes #18856 [backport] (#18879) 2021-09-22 09:43:06 +02:00
Jason Beetham
f8e185fec0 Fixed borrowing dot from aliases (#18854) 2021-09-16 08:48:58 +02:00
Jason Beetham
172253cb55 Dotborrow now works with generic distincts (#18848) 2021-09-14 19:34:52 +02:00
Jason Beetham
5d1608c976 Generic pointer procs now error if no types supplied (#18832)
* more precise logic for pointer procs

* added test for generic pointer procs

* Fixed generic getting bracket expr if erroring
2021-09-11 22:20:22 +02:00
Jason Beetham
30d28bcefc Fixes implicit and explicit generics in procedures (#18808)
* Fixes implicit and explicit generics

* moved block logic into 'maybeInstantiateGeneric'

* Added more tests

* Update compiler/semexprs.nim

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2021-09-06 20:11:21 +02:00
Jason Beetham
90bfd34250 '[]' can now be used for iterators (#18814) 2021-09-06 15:30:49 +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
a273ea70e8 implements overloadable enum values; WIP (#18470)
* implements overloadable enum values
* simpler code
2021-07-28 12:46:28 +02:00
Andreas Rumpf
f4ff276a90 refactoring: removed dead code (#18567) 2021-07-24 00:30:02 +02:00
Andreas Rumpf
70fb377e88 undo RFC #294, it breaks code for no good reason, the compiler can wa… (#18546)
* undo RFC #294, it breaks code for no good reason, the compiler can warn about the construct instead

* Update changelog.md

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>

* enable test case

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
2021-07-21 08:51:03 +02:00
Timothee Cour
836b061ae3 improve --declaredLocs to help disambiguate types (generics, aliases etc) (#18389)
* improve --declaredlocs to help disambiguate types (generics, aliases etc)

* avoid a cyclic deps

* fix test after rebase
2021-07-08 12:28:06 +02:00
Andreas Rumpf
97fc95012d fixes #16270 (#18388) 2021-06-29 15:34:39 +02:00
Timothee Cour
87cd9b24a3 add more APIs to compiler/debugutils; re-export it (#18243) 2021-06-18 15:52:08 +02:00
Timothee Cour
c83ac16671 Renamed -d:nimCompilerStackraceHints to -d:nimCompilerStacktraceHints. (#18283) 2021-06-17 00:17:46 -07:00
Andreas Rumpf
f65f760dee fixes #15884 (#18230)
* fixes #15884

* micro optimization
2021-06-10 18:19:20 +02:00
Andreas Rumpf
f10eef29b5 fixes #18059 (#18140)
* fixes #18059
2021-06-02 13:13:23 +02:00
Andreas Rumpf
378ee7f888 feature: the compiler can warn when you use the implicit 'result' variable (#17988) [backport:1.2]
* implements #17855
2021-05-10 23:41:51 +02:00
flywind
6e8f0f8cfc add colon (#17834) 2021-04-24 18:33:29 +01:00
Timothee Cour
2abc936d51 typeof(voidStmt) now works (#17807)
* `typeof(voidStmt)` now works
* remove typeOrVoid
* add condsyms, and reference cligen https://github.com/c-blake/cligen/pull/193
* fixup
* changelog [skip ci]
* fixup
2021-04-23 14:36:38 +02:00
flywind
4471141a1d fix #7535(Poor error message for spawn when a procedure (without calling it)) (#17774) 2021-04-21 17:53:31 +02:00
Clyybber
80389b8053 Revert localErrorNode param order changes (#17809)
* Revert localErrorNode param order changes

* Remove unused globalError overload

* heh
2021-04-21 16:03:30 +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
Timothee Cour
7e94420847 cString => cSourceString; tyCString => tyCstring so that error msgs show cstring, not cString (#17744) 2021-04-17 11:14:09 +02:00
Tanguy Cizain
363467fc00 Fix array's high & low return type for empty arrays (#17705)
* fix array.high/low return type

* Add test for empty array low return type

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
2021-04-15 15:45:38 +02:00
Andreas Rumpf
67e28c07f9 IC: first steps towards 'nim check --def --ic:on' (#17714)
* IC: first steps towards 'nim check --def --ic:on'
* IC navigator: deduplicate output lines
* IC navigator: progress
* IC navigator: use a different nimcache entry
* IC navigator: special logic for templates/macros
* IC navigator: proper error messages
* IC navigator: prepare for testing code; document only what currently works somewhat
2021-04-14 16:44:37 +02:00