Commit Graph

822 Commits

Author SHA1 Message Date
hlaaftana
f91867aa31 accept object type node from macros (#19179) 2021-11-24 16:34:42 +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
Timothee Cour
ceadf54d76 iterable[T] (#17196)
* fix failing test toSeq in manual which now works
* changelog
* reject proc fn(a: iterable)
* add iterable to spec
* remove MCS/UFCS limitation that now works
2021-04-11 14:25:41 +02:00
Andreas Rumpf
444658fe58 fixes #17656 (#17657) 2021-04-07 07:46:45 +02:00
Timothee Cour
270964c487 implement RFCs/294 ; disallow enum <=> enum conversion (#16351)
* fix https://github.com/nim-lang/RFCs/issues/294 ; disallow enum <=> enum conversion
* fix the runnableExamples that was the instigator of this RFC
* legacy -d:nimLegacyConvEnumEnum
* use -d:nimLegacyConvEnumEnum in important_package nimgame2
* add test for enum cast
* improve changelog
* add changelog: Changes affecting backward compatibility
* cleanup changelog
* fix changelog
2021-04-03 07:15:21 +02:00
Andreas Rumpf
6c1c8f51b3 IC: green tests (#17311)
* IC: renamed to_packed_ast module to ic module

* IC: don't store the --forceBuild flag, makes it easier to test

* IC: enable hello world test

* Codegen: refactorings for IC; changed the name mangling algorithm

* fixed the HCR regressions

* life is too short for HCR

* tconvexhull is now allowed to use deepCopy

* IC exposed a stdlib bug, required a refactoring

* codegen: code cleanups

* IC: even if a module is outdated, its dependencies might come from disk

* IC: progress

* IC: better name mangling, module IDs are not stable

* IC: another refactoring helping with --ic:on --gc:arc

* disable arraymancer on Windows for the time being

* disable arraymancer altogether

* IC: make basic test work with 'nim cpp'

* IC: progress on --ic:on --gc:arc

* wip; name mangling for type info
2021-03-19 16:53:38 +01:00
Saem Ghani
72b89eff82 semLambda removed, semProcAux reworked (#17379)
* simplified proc-like name ident to symbol code

* wip - reworking generic param sem

* wip - closer to removing nkEmpty generic params

* it's hacky but tests pass

* slowly tweaking semProcAux to take on semLambda

* fix pragma superset check proto vs current

* Set the symbol owner earlier

* partial progress reworking proto

found bug where default values between forward and impl lead to overload
resolution issues.

* simplified pragma handling and callConv checks

Co-authored-by: Clyybber <Clyybber@users.noreply.github.com>

* partially working

* cgexprs issue

* It works!

* comment clean-up

* clean-up asserts, comments, and other bits

* add isGenericParams, inline isGeneric queries

* seeing if this is sufficiently consistent
* can use this approach or continue it in a further PR

* commentary about nullary generics and clean-ups

* fixed a mistake in PNode isGenericRoutine

* Some small cleanups

* Small cleanup

* for func lambdas ensure we use lambda pragmas

* add some basic compileTime func tests

* [ci skip] remove comments

Co-authored-by: Clyybber <Clyybber@users.noreply.github.com>
Co-authored-by: Clyybber <darkmine956@gmail.com>
2021-03-17 19:51:50 +01:00
Andreas Rumpf
2f213db7ee 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'
2021-03-09 20:19:24 +01:00
quantimnot
b2b23d723a Fix macros.quote custom op symbol interpolation. (#17256)
Provides a workaround/fix for #7589.
https://github.com/nim-lang/Nim/issues/7589

Updated docs and tutorial to reflect change.

Updated runnableExamples to include an example.

Co-authored-by: name <name@example.com>
2021-03-05 14:41:33 +01:00
Saem Ghani
2aba116bbc when statements branches exit early (#17143)
When statement branches exit early outside of nimvm. In nimvm it seems that all
sides of the branches must be evaluated as the code gen happens at a later
stage, this remains intact.
2021-02-22 12:27:23 +01:00
Saem Ghani
260a5dacb7 fixed dot operator recursive loop & macro suggest (#16922)
* basic stability improvements; refs nimsuggest
* fixed dot operator recursive loop & macro suggest
* hacky fix for run away dot operator sem check

Committing this mostly to make the issue more clear. Perhaps get better
feedback.

* semExprWithType seems like a better place to check
* fixed error messages const case expressions
* Clean-up test
* stopped the dot operator madness

No longer get infinite recursion when seming broken code with a dot
operator macro like in jsffi.

Co-authored-by: Araq <rumpf_a@web.de>
2021-02-15 09:51:05 +01:00
flywind
d447c0fe3f use typeof instead type (#16962) 2021-02-08 09:46:07 +01:00
Andreas Rumpf
fb80d2ff85 IC: bugfixes (WIP) (#16836)
* minor improvements
* IC: added the required logic for compilerProcs
* LazySym ftw
* we need this testing logic
* reimplement the old way we use for module package creation
* fixes a regression; don't pick module names if you can avoid it
2021-02-02 19:24:55 +01:00
Andreas Rumpf
1fd4c666dc IC: next steps (#16705)
* code cleanups
* refactorings for IC
* more refactorings for IC
* IC: attach the 'nil' type to its module
* IC: refactorings and improvements
* IC: progress
* IC: more serialization fixes
* IC: embarrassing omission
* code cleanups
2021-01-14 17:30:41 +01:00
Andreas Rumpf
796498525a IC: next steps (#16550)
* cleanups
* ast.nim: cleanups
* IC: no more sym.tab field, stored externally in the module graph
* nimble compiles again
* rodfiles: store bitwidth of integers and the endianness in the cookie because we serialize 'int' directly
* rodfiles: added compilerproc and export sections
* rodfiles: added all the missing sections
* rodfiles: track the missing information
* IC: architecture for lazy loading of proc bodies
* make tests green again
* completed the lazy loading of proc bodies
* symbol lookup integration, part 1
* symbol lookup integration, part 2
* symbol lookup integration, part 3
* make tcompilerapi work again
* rodfiles: fixed config change handling
2021-01-07 20:26:40 +01:00
flywind
b8775bff57 fix is "closure" (#16552) 2021-01-02 17:11:46 +01:00
Andreas Rumpf
73a8b950cb big steps torwards an efficient, simple IC implementation (#16543)
* reworked ID handling
* the packed AST now has its own ID mechanism
* basic serialization code works
* extract rodfiles to its own module
* rodfiles: store and compare configs
* rodfiles: store dependencies
* store config at the end
* precise dependency tracking
* dependency tracking for rodfiles
* completed loading of PSym, PType, etc
* removed dead code
* bugfix: do not realloc seqs when taking addr into an element
* make IC opt-in for now
* makes tcompilerapi green again
* final cleanups

Co-authored-by: Andy Davidoff <github@andy.disruptek.com>
2021-01-02 07:30:39 +01:00
Andreas Rumpf
979148e863 refactorings to prepare the compiler for IC (#15935)
* added ic specific Nim code; WIP
* make the symbol import mechanism lazy; WIP
* ensure that modules can be imported multiple times
* ambiguity checking
* handle converters and TR macros properly
* make 'enum' test category green again
* special logic for semi-pure enums
* makes nimsuggest tests green again
* fixes nimdata
* makes nimpy green again
* makes more important packages work
2020-12-17 08:01:36 +01:00
Timothee Cour
f344a70412 fix #16150 improve type mismatch errors (#16152)
* fix #16150 improve type mismatch errors

* allow -d:nimLegacyTypeMismatch

* address comment
2020-12-09 16:19:39 +01:00
Timothee Cour
52829fc8d1 cmdline: improve command processing (#16056) 2020-11-26 15:55:56 -08:00
cooldome
acf8316e50 Disallow nil dereference at compile time (#16032)
* bring back the semfold of nil

* remove space

* fix test

* proc type can't be dereferenced

* disallow nil dereference at compile time

* changelog
2020-11-18 23:30:28 +01:00
Miran
bbe49a14ae Correct all eggs (#15906)
* "eg" is a misspelled "egg", "e.g." is "exempli gratia"
* Also, "ie" is "i.e.".
2020-11-10 21:53:25 +01:00