summary refs log tree commit diff stats
path: root/compiler
Commit message (Collapse)AuthorAgeFilesLines
* fixes #20162; locals doesn't work with ORC [backport] (#20163)ringabout2022-08-231-1/+1
| | | fixes #20162; locals doesn't work with ORC
* document compiler procs regarding `&` (#20257)ringabout2022-08-223-2/+8
|
* fixes #11953; jsondoc creates no files unless the htmldocs dir is created ↵ringabout2022-08-201-0/+2
| | | | | | | | | (#20198) * fixes #11953; jsondoc creates no files unless the htmldocs dir is created * target * fixes runner
* fixes #20149; fixes #16762; hintAsError and warningAsError now ignore ↵ringabout2022-08-191-7/+5
| | | | | | | | | | | | | | | | | | | 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>
* make implicit cstring conversions explicit (#19488)ee72022-08-192-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Nim manual says that an implicit conversion to cstring will eventually not be allowed [1]: A Nim `string` is implicitly convertible to `cstring` for convenience. [...] Even though the conversion is implicit, it is not *safe*: The garbage collector does not consider a `cstring` to be a root and may collect the underlying memory. For this reason, the implicit conversion will be removed in future releases of the Nim compiler. Certain idioms like conversion of a `const` string to `cstring` are safe and will remain to be allowed. And from Nim 1.6.0, such a conversion triggers a warning [2]: A dangerous implicit conversion to `cstring` now triggers a `[CStringConv]` warning. This warning will become an error in future versions! Use an explicit conversion like `cstring(x)` in order to silence the warning. However, some files in this repo produced such a warning. For example, before this commit, compiling `parsejson.nim` would produce: /foo/Nim/lib/pure/parsejson.nim(221, 37) Warning: implicit conversion to 'cstring' from a non-const location: my.buf; this will become a compile time error in the future [CStringConv] /foo/Nim/lib/pure/parsejson.nim(231, 39) Warning: implicit conversion to 'cstring' from a non-const location: my.buf; this will become a compile time error in the future [CStringConv] This commit resolves the most visible `CStringConv` warnings, making the cstring conversions explicit. [1] https://github.com/nim-lang/Nim/blob/d2318d9ccfe6/doc/manual.md#cstring-type [2] https://github.com/nim-lang/Nim/blob/d2318d9ccfe6/changelogs/changelog_1_6_0.md#type-system
* fixes #20107 (#20246) [backport]Andreas Rumpf2022-08-191-0/+14
|
* Don't require blank line before Markdown code (#20215)Andrey Makarov2022-08-151-2/+1
| | | | Fixes bug reported in https://github.com/nim-lang/Nim/pull/20189 affecting nimforum.
* bootstrap the compiler with nimPreviewSlimSystem (#20176)ringabout2022-08-098-1/+26
| | | | | * bootstrap the compiler with nimPreviewSlimSystem * threads
* fixes #20132; fixes the broken jsondoc comand [backport] (#20135)ringabout2022-08-041-1/+2
| | | | | * fixes #20132; fixes the broken jsondoc comand * add testcase
* Fixed compilation of void closureiters with try stmt (#20138) [backport]Yuriy Glukhov2022-08-031-4/+7
|
* Warn when casting to a larger type (#20103)konsumlamm2022-07-282-8/+12
| | | | | * Warn when casting to a larger type * Revert change to error message to fix CI
* Fixed noinit pragma for closure variables (#20101)Yuriy Glukhov2022-07-282-2/+3
|
* fixes #20031; uint64 is an ordinal type since 1.0 (#20094)ringabout2022-07-271-1/+1
| | | | | * fixes #20031; uint64 is an ordinal type since 1.0 * Update compiler/semstmts.nim
* remove shallowCopy for ARC/ORC (#20070)ringabout2022-07-265-9/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | * remove shallowCopy for ARC/ORC * use move * fix * more fixes * typo * Update lib/system.nim * follow * add nodestroy * move * copy string * add a changelog entry Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com> Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* .forbids pragma: defining forbidden tags (#20050)Lancer112112022-07-269-17/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * .forbids pragma: defining illegal effects for proc types This patch intends to define the opposite of the .tags pragma: a way to define effects which are not allowed in a proc. * updated documentation and changelogs for the forbids pragma * renamed notTagEffects to forbiddenEffects * corrected issues of forbids pragma the forbids pragma didn't handle simple restrictions properly and it also had issues with subtyping * removed incorrect character from changelog * added test to cover the interaction of methods and the forbids pragma * covering the interaction of the tags and forbids pragmas * updated manual about the forbids pragma * removed useless statement * corrected the subtyping of proc types using the forbids pragma * updated manual for the forbids pragma * updated documentations for forbids pragma * updated nim docs * updated docs with rsttester.nim * regenerated documentation * updated rst docs * Update changelog.md Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> * updated changelog * corrected typo Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* Correctly detect major version of GCC (#20059)kraptor2022-07-181-20/+6
| | | | | | | | | | | | | | | We were doing a very poor job detecting the major version of GCC by parsing the output of --version. This patches uses -dumpversion to make this parsing straightforward and it also fixes a bunch of compiling issues on different platforms with custom output for --version switches. For example, openSUSE first line of the output includes the revision number and the parsing that was being done did mix that number with the major version and breaks building the nim compiler (as it doesn't find the 3 dots for an X.Y.Z semver format, hence returning "false"). In this patch, we simply use -dumpversion (which has been at least from 1993, so we are safe :)
* defines the `gcRefc` symbol which allows writing specific code for refc (#20009)flywind2022-07-171-0/+1
| | | | | | | | | | | | | | | | | | * define gcRefc symbols * add comments * add a changelog item * Update changelog.md Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> * Update changelog.md Co-authored-by: Yardanico <tiberiumk12@gmail.com> Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> Co-authored-by: Yardanico <tiberiumk12@gmail.com>
* Make imports/exports not be a dropdown in sidebar (#19907)Jake Leahy2022-07-161-3/+14
| | | | | | | | | * Don't make a section be a dropdown if it has no child links * - Cleaned up code - Updated tests * Document what the 'if' is checking
* Use module actual file instead of PSym.info (#19956)Ivan Yonchovski2022-07-151-12/+18
| | | After this you can do goto module from module import
* Implement type command (#19944)Ivan Yonchovski2022-07-151-1/+3
| | | | | | | | | | | * Implement type command - this will be mapped to textDocument/typeDefinition in LSP protocol. It will be very useful for `nim` in particular because typically most of the time the type is inferred. * Update nimsuggest/nimsuggest.nim Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Improve Markdown code blocks & start moving docs to Markdown style (#19954)Andrey Makarov2022-07-156-21/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - add additional parameters parsing (other implementations will just ignore them). E.g. if in RST we have: .. code:: nim :test: "nim c $1" ... then in Markdown that will be: ```nim test="nim c $1" ... ``` - implement Markdown interpretation of additional indentation which is less than 4 spaces (>=4 spaces is a code block but it's not implemented yet). RST interpretes it as quoted block, for Markdown it's just normal paragraphs. - add separate `md2html` and `md2tex` commands. This is to separate Markdown behavior in cases when it diverges w.r.t. RST significantly — most conspicously like in the case of additional indentation above, and also currently the contradicting inline rule of Markdown is also turned on only in `md2html` and `md2tex`. **Rationale:** mixing Markdown and RST arbitrarily is a way to nowhere, we need to provide a way to fix the particular behavior. Note that still all commands have **both** Markdown and RST features **enabled**. In this PR `*.nim` files can be processed only in Markdown mode, while `md2html` is for `*.md` files and `rst2html` for `*.rst` files. - rename `*.rst` files to `.*md` as our current default behavior is already Markdown-ish - convert code blocks in `docgen.rst` to Markdown style as an example. Other code blocks will be converted in the follow-up PRs - fix indentation inside Markdown code blocks — additional indentation is preserved there - allow more than 3 backticks open/close blocks (tildas \~ are still not allowed to avoid conflict with RST adornment headings) see also https://github.com/nim-lang/RFCs/issues/355 - better error messages - (other) fix a bug that admonitions cannot be used in sandbox mode; fix annoying warning on line 2711
* fix #20002 (#20004)metagn2022-07-151-1/+1
| | | | | | While this fix seems innocent, this unlocks the hidden behavior of method calls not being able to call gensym'ed routines inside templates.
* Change `styleCheck` to ignore foreign packages (#19822)quantimnot2022-07-1415-108/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* fix #20012 (#20013)Daniel Clarke2022-07-131-1/+1
| | | | | | | * replace gcc asm with __asm__ and add a test * update test case to specify gcc or clang and not cpp Co-authored-by: daniel <danielclarke@wearepopgun.com>
* fix #18735; genDepend broken for duplicate module names in separate folders ↵flywind2022-07-122-8/+52
| | | | (#19988)
* allow dots in defined() (#20010)metagn2022-07-121-1/+13
| | | | | | | * allow dots in defined() refs https://github.com/nim-lang/RFCs/issues/181 * mention accents in older versions
* try to optimize hot spots for orc-booting compiler (#20001)flywind2022-07-121-5/+13
| | | | | | | | | | | | | | | * optimize hot spots fro orc-booting compiler * remove GC_ref * minor * remove comments * Revert "minor" This reverts commit 4965a190a2d6457044faa1442795e55bdad57602. * emulate cursor
* Fix nested finally handling in closureiters [backport] (#19933)Tanguy2022-07-111-6/+25
| | | | | | | | | | | | | | | * Fix nested finally handling in closureiters * Fix CI * review comment * third time the charm * Update compiler/closureiters.nim Co-authored-by: Dominik Picheta <dominikpicheta@googlemail.com> Co-authored-by: Dominik Picheta <dominikpicheta@googlemail.com>
* remove `when declared(cache)`; cache is always there (#19991)flywind2022-07-101-9/+6
|
* removed caching logic; saves 400MB for an ORC booting compiler (#19989)Andreas Rumpf2022-07-091-8/+1
|
* cache rope when threads are enabled (#19981)flywind2022-07-071-6/+5
| | | | | * cache rope * add threadvar
* rename gc to mm (#19971)flywind2022-07-051-1/+1
|
* Fixing `nimRawSetJmp` for vcc and clangcl on Windows (#19959)rockcavera2022-07-041-7/+12
| | | | | | | | | | | | | * fix vcc rawsetjmp * changing `_longjmp()` to `longjmp()` and `_setjmp()` to `setjmp()` * fix * fix setjmp to clangcl on Windows * fix genTrySetjmp() to clangcl on Windows
* Allow recursive closure iterators (#19939)Tanguy2022-06-301-1/+2
|
* once C++, always C++ [backport] (#19938)Jacek Sieka2022-06-301-10/+16
| | | | | | | | | | | * once C++, always C++ When using `{.compile: "file.cc".}` in a nim module, even when compiling with `nim c` the C++ compiler should be used - once any C++ file has been compiled, the C++ linker also needs to be used. * more strict C++ check * simplify code
* dec inLoop after exiting the while scope in computeLiveRanges [backport] ↵flywind2022-06-291-1/+1
| | | | | | | (#19918) * dec inLoop after exiting the while scope in computeLiveRanges * add testcase
* ref #19830; multiple definition of in Nim generated static libraries (#19934)flywind2022-06-271-18/+18
| | | | | * ref #19830; multiple definition of in Nim generated static libraries * fix compile errors
* [vm]fixes #15974 #12551 #19464 #16020 #16780 #16613 #14553 #19909 #18641 ↵flywind2022-06-222-13/+18
| | | | | | | | | | | | | | | (#19902) [backport] * revert #12217 since the root problem seems to have been fixed; fix #15974;fix #12551; fix #19464 * fix #16020; fix #16780 * fix tests and #16613 * fix #14553 * fix #19909; skip skipRegisterAddr * fix #18641
* [Tiny] correct comment opcDeref => opcLdDeref (#19908)flywind2022-06-211-1/+1
| | | correct comment opcDeref => opcLdDeref
* [vm] refactor `stdlib.marshal.load` (#19905)flywind2022-06-191-17/+1
| | | refactor stdlib.marshal.load
* Better range error messages (#19867)Tanguy2022-06-151-3/+3
| | | | | | | * Better range error messages * Revert to old behavior for arrays * Small corrections
* Fixes #19883 so genscript works with vcc (#19893)Don-Duong Quach2022-06-151-2/+8
|
* Initial implementation of nimsuggest v3 (#19826)Ivan Yonchovski2022-06-134-21/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Initial implementation of nimsuggest v3 Rework `nimsuggest` to use caching to make usage of ide commands more efficient. Previously, all commands no matter what the state of the process is were causing clean build. In the context of Language Server Protocol(LSP) and lsp clients this was causing perf issues and overall instability. Overall, the goal of v3 is to fit to LSP Server needs - added two new commands: - `recompile` to do clean compilation - `changed` which can be used by the IDEs to notify that a particular file has been changed. The later can be utilized when using LSP file watches. - `globalSymbols` - searching global references - added `segfaults` dependency to allow fallback to clean build when incremental fails. I wish the error to be propagated to the client so we can work on fixing the incremental build failures (typically hitting pointer) - more efficient rebuild flow. ATM incremental rebuild is triggered when the command needs that(i. e. it is global) while the commands that work on the current source rebuild only it Things missing in this PR: - Documentation - Extensive unit testing. Although functional I still see this more as a POC that this approach can work. Next steps: - Implement `sug` request. - Rework/extend the protocol to allow better client/server communication. Ideally we will need push events, diagnostics should be restructored to allow per file notifications, etc. - implement v3 test suite. - better logging * Add tests for v3 and implement ideSug * Remove typeInstCache/procInstCache cleanup * Add ideChkFile command * Avoid contains call when adding symbol info * Remove log * Remove segfaults
* [semfold] fix #19199; properly fold uint to float conversion (#19890) [backport]flywind2022-06-131-1/+1
| | | fix #19199; properly fold float conversion
* [cleanup] remove unnecessary procs in vm (#19888)flywind2022-06-132-6/+2
| | | remove unused procs
* Friendlier error message with solution (#19880)Carlo Capocasa2022-06-111-1/+2
| | | | | | | | | | | | | * Add helpful suggestion, should always apply * mention var param limitation in async docs * Update compiler/lambdalifting.nim whoops thanks Co-authored-by: flywind <43030857+xflywind@users.noreply.github.com> Co-authored-by: flywind <43030857+xflywind@users.noreply.github.com>
* Extend and document compiler debugging utilities (#19841)quantimnot2022-06-101-0/+16
| | | | | | | | | * Add two debugutils procs that native debuggers can break on use to execute commands when code of interest is being compiled. * Add GDB and LLDB programs to disable and enable breakpoints and watchpoints when code of interest is being compiled. * Extend the `intern.rst` docs regarding debugging the compiler. Co-authored-by: quantimnot <quantimnot@users.noreply.github.com>
* remove noop option `gc:v2` (#19810)flywind2022-06-104-6/+3
| | | | | * remove noop option gc:v2 * changelog
* not generate initStackBottomWith in arc/orc [backport] (#19875)flywind2022-06-101-1/+1
| | | not generate initStackBottomWith in arc/orc
* give a better error message for some template expansions (#19871)Andreas Rumpf2022-06-091-2/+4
|