Commit Graph

545 Commits

Author SHA1 Message Date
ringabout
36bf3fa47b fixes #23556; typeinfo.extendSeq generates random values in ORC (#23557)
fixes #23556

It should somehow handle default fields in the future
2024-05-03 22:29:56 +08:00
metagn
fc49c6e3ba fix spurious indent and newlines in rendering of nkRecList (#23121)
Rendering of `nkRecList` produces an indent and adds a new line at the
end. However for things like case object `of`/`else` branches or `when`
branches this is already done, so this produces 2 indents and an extra
new line. Instead, just add an indent in the place where the indent that
`nkRecList` produces is needed, for the rendering of the final node of
`nkObjectTy`. There doesn't seem to be a need to add the newline.

Before:

```nim
case x*: bool
of true:
    y*: int

of false:
  nil
```

After:

```nim
case x*: bool
of true:
  y*: int
of false:
  nil
```
2023-12-24 15:22:10 +01:00
ringabout
0f54554213 allow non var deinit for locks and conds: alternative way (#23099)
alternative to https://github.com/nim-lang/Nim/pull/23092
2023-12-19 09:47:39 +01:00
Jake Leahy
b3b87f0f8a Mark macros.error as .noreturn. (#23081)
Closes #14329 

Marks `macros.error` as `.noreturn` so that it can be used in
expressions. This also fixes the issue that occurred in #19659 where a
stmt that could be an expression (Due to having `discardable` procs at
the end of other branches) would believe a `noreturn` proc is returning
the same type e.g.
```nim
 proc bar(): int {.discardable.} = discard

if true: bar()
else: quit(0) # Says that quit is of type `int` and needs to be used/discarded except it actually has no return type
```
2023-12-17 12:29:46 +01:00
ringabout
4d11d0619d complete std prefixes for stdlib (#22887)
follow up https://github.com/nim-lang/Nim/pull/22851
follow up https://github.com/nim-lang/Nim/pull/22873
2023-10-30 17:03:04 +01:00
Amjad Ben Hedhili
d77ada5bdf Markdown code blocks migration part 9 (#22506)
* Markdown code blocks migration part 9

* fix [skip ci]
2023-08-19 15:14:56 +02:00
Jake Leahy
d3af0882cf BackwardsIndex overload for CacheSeq.[] (#22043)
* Add `BackwardsIndex` support for `CacheSeq`

* Add changelog entry

---------

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2023-06-10 14:43:32 +02:00
metagn
9810b8cf7f just set CallNodes = nnkCallKinds, follows up #21829 (#21833)
These sets are now equal
2023-05-11 20:50:01 +02:00
Matt Wilson
802d57c237 Add nnkHiddenCallConv to nnkCallKinds (#21781) (#21829) 2023-05-11 20:14:44 +08:00
chmod222
0c6f14af04 macros: Extend treeTraverse intVal range to nnkUInt64Lit (#21597)
* Extend intVal range to nnkUInt64Lit

Fixes #21593

* Properly cast intVal as unsigned

* Add testcase for #21593
2023-04-01 20:29:28 +02:00
Jake Leahy
900fe8f501 Add contains to std/macrocache (#21304)
* Add test cases

* Implement contains for CacheSeq

* Implement contains for CacheTable

* Fix implementation of hasKey

* Remove contains for CacheSeq

Fix runnable examples

I was accidently using --doccmd:skip so I didn't spot the failure locally

* Implement hasKey as a VM callback instead of magic

* Implement suggestions from PR

Co-Authored-By: ringabout <ringabout@users.noreply.github.com>

* Update lib/core/macrocache.nim

---------

Co-authored-by: ringabout <ringabout@users.noreply.github.com>
Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
2023-02-01 10:00:10 +01:00
Jake Leahy
1e52423774 Fix getting custom pragma from generic object (#20481)
* Merge devel

Add another test case

* Fix test

Use getCustomPragmaVal instead of hasCustomPragma

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
2023-01-11 20:44:33 -05:00
Andrey Makarov
2620da9bf9 docgen: implement cross-document links (#20990)
* docgen: implement cross-document links

Fully implements https://github.com/nim-lang/RFCs/issues/125
Follow-up of: https://github.com/nim-lang/Nim/pull/18642 (for internal links)
and https://github.com/nim-lang/Nim/issues/20127.

Overview
--------

Explicit import-like directive is required, called `.. importdoc::`.
(the syntax is % RST, Markdown will use it for a while).

Then one can reference any symbols/headings/anchors, as if they
were in the local file (but they will be prefixed with a module name
or markup document in link text).
It's possible to reference anything from anywhere (any direction
in `.nim`/`.md`/`.rst` files).

See `doc/docgen.md` for full description.

Working is based on `.idx` files, hence one needs to generate
all `.idx` beforehand. A dedicated option `--index:only` is introduced
(and a separate stage for `--index:only` is added to `kochdocs.nim`).

Performance note
----------------

Full run for `./koch docs` now takes 185% of the time before this PR.
(After: 315 s, before: 170 s on my PC).
All the time seems to be spent on `--index:only` run, which takes
almost as much (85%) of normal doc run -- it seems that most time
is spent on file parsing, turning off HTML generation phase has not
helped much.
(One could avoid it by specifying list of files that can be referenced
and pre-processing only them. But it can become error-prone and I assume
that these linke will be **everywhere** in the repository anyway,
especially considering https://github.com/nim-lang/RFCs/issues/478.
So every `.nim`/`.md` file is processed for `.idx` first).

But that's all without significant part of repository converted to
cross-module auto links. To estimate impact I checked the time for
`doc`ing a few files (after all indexes have been generated), and
everywhere difference was **negligible**.
E.g. for `lib/std/private/osfiles.nim` that `importdoc`s large
`os.idx` and hence should have been a case with relatively large
performance impact, but:

* After: 0.59 s.
* Before: 0.59 s.

So Nim compiler works so slow that doc part basically does not matter :-)

Testing
-------

1) added `extlinks` test to `nimdoc/`
2) checked that `theindex.html` is still correct
2) fixed broken auto-links for modules that were derived from `os.nim`
   by adding appropriate ``importdoc``

Implementation note
-------------------

Parsing and formating of `.idx` entries is moved into a dedicated
`rstidx.nim` module from `rstgen.nim`.

`.idx` file format changed:

* fields are not escaped in most cases because we need original
  strings for referencing, not HTML ones
  (the exception is linkTitle for titles and headings).
  Escaping happens later -- on the stage of `rstgen` buildIndex, etc.
* all lines have fixed number of columns 6
* added discriminator tag as a first column,
  it always allows distinguish Nim/markup entries, titles/headings, etc.
  `rstgen` does not rely any more (in most cases) on ad-hoc logic
  to determine what type each entry is.
* there is now always a title entry added at the first line.
* add a line number as 6th column
* linkTitle (4th) column has a different format: before it was like
  `module: funcName()`, now it's `proc funcName()`.
  (This format is also propagated to `theindex.html` and search results,
  I kept it that way since I like it more though it's discussible.)
  This column is what used for Nim symbols resolution.
* also changed details on column format for headings and titles:
  "keyword" is original, "linkTitle" is HTML one

* fix paths on Windows + more clear code

* Update compiler/docgen.nim

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

* Handle .md and .nim paths uniformly in findRefFile

* handle titles better + more comments

* don't allow markup overwrite index title for .nim files

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2023-01-04 15:19:01 -05:00
ringabout
f7c203fb6c remove legacy code (#21134)
* remove legacy code

* fixes
2022-12-26 13:20:05 +01:00
Peter Munch-Ellingsen
613829f7a4 Implement setLineInfo (#21153)
* Implement setLineInfo

* Add tests
2022-12-22 04:34:36 +01:00
Bung
a9bd78d579 fix #12122 (#21096) 2022-12-16 08:01:15 +01:00
Emery Hemingway
696def2bf7 macros.customPragmaNode: walk brackets on brackets (#21040) 2022-12-08 10:57:26 +01:00
ringabout
1dab8ba334 move threads out of system (#20674)
* move syslocks first

* progress

* clean up

* go on

* clean up

* clean up

* add imports syslocks

* remove documentation

* public deallocOsPages

* fixes genode

* fixes more

* fixes boehmGC

* cover more cases

* fixes cyclic deps

* fixes genode

* cleanup

* unpublic fields

* cleanup

* clean up
2022-10-29 18:11:40 +02:00
Andreas Rumpf
81087c949f fixes #20572 (#20585)
* fixes #20572

* added a test case
2022-10-17 23:48:51 +02:00
ringabout
5602183234 'lock levels' are deprecated, now a noop (#20539)
* 'lock levels' are deprecated, now a noop

* fixes tests
2022-10-11 09:17:09 +02:00
Andreas Rumpf
e83f27e6a0 out parameters: enforce that 'out' is only used as a parameter (#20510)
* out parameters: enforce that 'out' is only used as a parameter

* make tables.nim use 'out' parameters

* better backwards compat
2022-10-07 22:26:53 +02:00
metagn
919a889ba8 moderate system cleanup & refactor (#20355)
* system refactor, move out 600 lines

* compilation, slice, backwardsindex, misc_num moved out of system
* some procs/types moved into arithmetics, basic_types
* system no longer depends on syncio
* some procs moved around to fit with their surroundings

* make exceptions an import, old ops to misc_num

* move instantiationInfo back

* move back nim version, fix windows echo

* include compilation

* better docs for imported modules, fix unsigned ops

also remove ze, ze64, toU8, toU16, toU32 with nimPreviewSlimSystem

* fix terminal

* workaround IC test & weird csize bug, changelog

* move NimMajor etc back to compilation, rebase for CI

* try ic fix

* form single `indices`, slim out TaintedString, try fix IC

* fix CI, update changelog, addQuitProc

* fix CI

* try fix CI

* actually fix CI finally hopefully

* Update lib/system/compilation.nim

Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>

* update kochdocs

* hopefully fix csize uses for slimsystem

* fix tquit

Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
2022-09-28 15:28:45 -04:00
metagn
de4b0346bd store full definition AST for consts, fix noRewrite (#20115)
* continue #9582 for consts, close #9331, fix #20114

also move extractPragma to ast to pave the way for things like {.strdefine: "abc".} etc

* changelog correctly

* fix jsgen

* update tgetimpl

* fix sighashes

* fix #19766, add comment about postfix

* fix noRewrite LOL

refs #16620

* fix changelog

* fix destructors
2022-09-28 15:05:01 +02:00
ringabout
3d2f0e2c7c make more standard libraries work with nimPreviewSlimSystem (#20343)
* make more standard libraries work with `nimPreviewSlimSystem`

* typo

* part two

* Delete specutils.nim

* fixes more tests

* more fixes

* fixes tests

* fixes three more tests

* add formatfloat import

* fix

* last
2022-09-27 20:06:23 +02:00
ringabout
d44b547144 add docs to copyNimNode and copyNimTree (#20357)
* add docs to copyNimNode and copyNimTree

* Apply suggestions from code review

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

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
2022-09-16 00:35:44 -04:00
ringabout
b2c5f6f3c8 give a deprecate warning when using newPar to construct tuple expressions (#20312)
* error/deprecate when using `newPar` to construct tuple expressions

* Update lib/core/macros.nim

* fixes
2022-09-06 21:38:08 +02:00
Andrey Makarov
cde6b2aab8 Implement Pandoc Markdown concise link extension (#20304)
* Implement Pandoc Markdown concise link extension

This implements https://github.com/nim-lang/Nim/issues/20127.
Besides reference to headings we also support doing references
to Nim symbols inside Nim modules.

Markdown:
```
Some heading
------------

Ref. [Some heading].
```

Nim:
```
proc someFunction*() ...

... ## Ref. [someFunction]
```

This is substitution for RST syntax like `` `target`_ ``.
All 3 syntax variants of extension from Pandoc Markdown are supported:
`[target]`, `[target][]`, `[description][target]`.

This PR also fixes clashes in existing files, particularly
conflicts with RST footnote feature, which does not work with
this PR (but there is a plan to adopt a popular [Markdown footnote
extension](https://pandoc.org/MANUAL.html#footnotes) to make footnotes work).

Also the PR fixes a bug that Markdown links did not work when `[...]`
section had a line break.

The implementation is straightforward since link resolution did not
change w.r.t. RST implementation, it's almost only about new syntax
addition. The only essential difference is a possibility to add a custom
link description: form `[description][target]` which does not have an
RST equivalent.

* fix nim 1.0 gotcha
2022-09-04 14:52:21 -04:00
Andrey Makarov
0f555110e6 Markdown code blocks part 6 (#20292) 2022-08-31 19:39:02 -04:00
ringabout
b6bfe38ff5 move formatfloat out of system (#20195)
* move formatfloat out of system

* fixes doc

* Update changelog.md

* careless

* fixes

* deprecate system/formatfloat

* better handling
2022-08-24 13:38:30 +02:00
metagn
685bf944aa fix #20067, fix #18976 [backport] (#20069) 2022-07-22 15:04:07 +08:00
ehmry
82680a12a7 macros: make hasCustomPragma more permissive (#19747)
Make hasCustomPragma return false rather than fail for invalid
parameters.
2022-04-25 22:16:11 +02:00
flywind
0978276ed9 use two spaces indentation (#19696) 2022-04-07 13:07:39 +08:00
flywind
c3f03cfa5d add somes links to docs (#19668) 2022-04-01 13:30:02 -04:00
flywind
7f6e800caf move assertions out of system (#19599) 2022-03-23 20:34:53 +01:00
Tanguy
ef3f343ec2 Allow std/macros.params to work with nnkProcTy (#19563)
* Allow std/macros.params to work with nnkProcTy

* Add tests for proc params & pragma
2022-02-25 12:57:58 +01:00
Regis Caillaud
486cb09ec2 Clonkk fix2 11923 (#19451)
* fix nnkBracketExpr not compiling for getImpl on customPragmaNode

* fix test import

* fix alias not working with hasCustomPragmas
2022-02-02 09:44:51 +01:00
Regis Caillaud
1563cb2f6e Fix #11923 (#19427)
* Apply commit 5da931fe81 that was never merged (was part of a bigger PR). Should fix issue #11932

* add a generic object for custom pragma
2022-01-20 20:50:36 +01:00
Hamid Bluri
5d303762f1 update deprecated example (#19415)
`toNimIdent` proc is deprecated, so I replaced it with `ident` proc
2022-01-18 15:55:39 -05:00
Jake Leahy
4da7dbffc5 Extract runnables that specify doccmd (#19275) [backport:1.6] 2021-12-20 17:29:03 +01:00
hlaaftana
c7c6b13a32 parseExpr/parseStmt accept filename, fixes #13540 (#19182) 2021-11-24 12:22:40 +01:00
hlaaftana
5933aece9b caseStmtMacros no longer experimental, experimental manual refactor (#19173)
* `caseStmtMacros` no longer experimental, experimental manual refactor

* Update doc/manual.rst

* apply review suggestions

* apply review

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2021-11-23 16:30:17 +01:00
Don-Duong Quach
f2f15e9726 fix for #19020, credit to @ElegantBeef (#19021) 2021-11-03 16:47:31 +01:00
Aditya Siram
e3b19cbe52 fixes #18878 (#18883) 2021-09-25 14:17:41 +02:00
Dankr4d
c70e4040bd fixes #14511 [backport:1.4] (#18732)
* fixes #14511 [backport:1.4]

Signed-off-by: Dankr4d <dude569@freenet.de>

* Replaced fix with code from alaviss, for better readability, with small
changes.

Signed-off-by: Dankr4d <dude569@freenet.de>

* - Specified output in test.

Signed-off-by: Dankr4d <dude569@freenet.de>

* Replaced case in nnkRecCase with a simpler version, which just adds the
last son.

Signed-off-by: Dankr4d <dude569@freenet.de>

* Update tests/macros/t14511.nim

* Update tests/macros/t14511.nim

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2021-08-25 17:27:00 +00:00
flywind
061a9183f7 replace wrt with proper word (#18724)
* what does wrt mean?

* clarify
2021-08-22 06:21:53 +02:00
Andreas Rumpf
4920b06973 fixes #18543 (#18601)
* fixes #18543

* make tests green again
2021-07-27 19:04:55 +02:00
Antonis Geralis
48ef832cf3 sync with the same template from locks module (#18414) 2021-07-10 08:41:07 +02:00
Timothee Cour
5600a62229 strformat.fmt now supports non-literal const strings (#18274)
Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2021-06-18 08:57:51 -07:00
flywind
5bad022d58 alternative to #18185 (#18206) 2021-06-07 15:32:37 +02:00
Timothee Cour
3cc547f2df macros.treeRepr + friends: collapse SymChoice (#18072)
* macros.treeRepr + friends: collapse SymChoice

* make repr+friends work with invalid symchoice nodes

* address comment
2021-06-05 06:58:26 +02:00