Commit Graph

245 Commits

Author SHA1 Message Date
ringabout
4eaecfe59e fixes #25027; nim doc uses doc comment from private field for public field (#25239)
fixes #25027

(cherry picked from commit b8ce11dd9d)
2025-10-27 08:51:12 +01:00
ringabout
6cc267ab19 fixes #25226; VM repr raises RangeDefect for long string under refc (#25230)
fixes #25226

`int16` seems to be too small for a reasonable VM program

(cherry picked from commit 1eae14a3be)
2025-10-20 13:44:44 +02:00
metagn
20ff258a08 clean up opensym encounters in compiler (#24866)
To protect against crashes when this stops being experimental, in most
places handled the exact same as normal symchoices (not encountered in
typed ast)

(cherry picked from commit 4d075dc301)
2025-04-14 10:52:41 +02:00
ringabout
c452d706ae fixes #24850; macro-generated if/else and when/else statements have m… (#24852)
…ismatched indentation with repr

fixes #24850

(cherry picked from commit 29a2e25d1e)
2025-04-09 07:54:44 +02:00
ringabout
4d170ac586 fixes #24258; compiler crash on len of varargs[untyped] (#24307)
fixes #24258

It uses conditionals to guard against ill formed AST to produce better
error messages, rather than crashing

(cherry picked from commit 8b39b2df7d)
2025-01-14 07:39:32 +01:00
metagn
1bd5a4a99e render float128 literals (#24182)
fixes #23639

Not sure if these are meant to be supported but it's better than
crashing.
2024-09-27 06:11:21 +02:00
metagn
0c890ff9a7 opensym as node kind + fixed experimental switch (#23892)
refs https://github.com/nim-lang/Nim/pull/23873#discussion_r1687995060,
fixes #23386, fixes #23385, supersedes #23572

Turns the `nfOpenSym` node flag implemented in #23091 and extended in
#23102 and #23873, into a node kind `nkOpenSym` that forms a unary node
containing either `nkSym` or `nkOpenSymChoice`. Since this affects
macros working on generic proc AST, the node kind is now only generated
when the experimental switch `genericsOpenSym` is enabled, and a new
node flag `nfDisabledOpenSym` is set to the `nkSym` or `nkOpenSymChoice`
when the switch is not enabled so that we can give a warning.

Now that the experimental switch has more reasonable semantics, we
define `nimHasGenericsOpenSym2`.
2024-08-12 15:33:26 +02: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
metagn
c0acf3ce28 retain postfix node in type section typed AST, with docgen fix (#23101)
Continued from #23096 which was reverted due to breaking a package and
failing docgen tests. Docgen should now work, but ~~a PR is still
pending for the package: https://github.com/SciNim/Unchained/pull/45~~
has been merged
2023-12-23 09:22:49 +01:00
Andreas Rumpf
db603237c6 Types: Refactorings; step 1 (#23055) 2023-12-12 16:54:50 +01:00
Jacek Sieka
e1a0ff1b8a lexer cleanups (#23037)
* remove some dead code and leftovers from past features
* fix yaml printing of uint64 literals
2023-12-06 18:17:57 +01:00
ringabout
e17237ce9d prepare for the enforcement of std prefix (#22873)
follow up https://github.com/nim-lang/Nim/pull/22851
2023-10-29 14:48:11 +01:00
ringabout
81b2ae747e fixes #8893; guard against array access in renderer (#22807)
fixes #8893
2023-10-09 15:36:56 +02:00
ringabout
f8f6a3c926 renderIr should print the actual return assign node (#22682)
follow up https://github.com/nim-lang/Nim/pull/10806

Eventually we need a new option to print high level IR. It's confusing
when I'm debugging the compiler without showing `return result = 1`
using the expandArc option.

For 
```nim
proc foo: int =
  return 2
```
It now outputs when expanding ARC IR
```nim
proc foo: int =
  return result = 2
```
2023-09-10 17:35:40 +02:00
metagn
4f891aa50c don't render underscore identifiers with id (#22538) 2023-08-23 13:43:02 +02:00
ringabout
28b2e429ef refactors initSrcGen and initTokRender into returning objects (#22421) 2023-08-09 06:40:17 +02:00
ringabout
93ced31353 use strictdefs for compiler (#22365)
* wip; use strictdefs for compiler

* checkpoint

* complete the chores

* more fixes

* first phase cleanup

* Update compiler/bitsets.nim

* cleanup
2023-08-06 14:26:21 +02:00
Ryan McConnell
2f817ee5b4 infixArgument fail in renderer.nim sometimes (#22264)
* fixing minor typo

* Adding err msg
2023-07-20 19:56:54 +02:00
Jake Leahy
17915d93bf Fix non-toplevel fields in objects not getting rendered (#22266)
* Add example object into testproject

The proc is there to check the case of an identDef being inside an identDef (We do want to render those even if they are not exported)

* Add `inside` set to `TSrcGen` which allows us to see what context we are in

This is done instead of adding another inXyz bool parameter

We then use this to know if we are inside an object when rendering an nkIdentDefs (To know if we need to skip rendering it)

* Update test files
2023-07-16 19:46:18 +02:00
metagn
71801c2b8f fix dot calls with resolved symbols in templates (#22076)
* fix dot calls with resolved symbols in templates

* make old code work

* fix custom number literals test

* remove leftover debug marker

* enable "bug 9" test too

* fix renderer, add test for #7085
2023-06-12 06:34:34 +02:00
metagn
02be212dae clean up SOME pending/xxx/issue link comments (#21826)
* clean up SOME pending/xxx/issue link comments

* great
2023-05-11 10:23:52 +02:00
ringabout
8e0f336f6d fixes #21483; fixes nim doc skips documentation of annotated elements of objects (#21743)
* fixes #21483; skipPragmaExpr

* add a test case for #21483

* fixes HTML
2023-04-29 15:30:44 +02:00
ringabout
ff8ab06720 fixes #19396; Nimdoc hide nonexported fields (#21305)
* suppresses non-exported fields of types and adds command-line option to re-enable this if desired

* corrected the doctest that produced a CI error

* an embarrassingly bad error in reasoning

* modified a nimdoc test to reflect updated behavior

* needed another change to bring utils.html doctest in sync with update

* add info

* fix nimdoc

* lint

* render postfix

* fixes a problem

* fixes nimdoc

* fix nimdoc

---------

Co-authored-by: johnperry-math <john.perry@usm.edu>
Co-authored-by: johnperry-math <devotus@yahoo.com>
2023-02-01 08:13:40 +01:00
ringabout
f7c203fb6c remove legacy code (#21134)
* remove legacy code

* fixes
2022-12-26 13:20:05 +01:00
Jake Leahy
d88f46df38 Make async stacktraces less verbose (#21091)
* Name iterators something human readable

Remove intermediate async procs from stacktraces

Clean async traceback message from reraises message

* Remove unused import/variable

* Fix failing tests

Don't add {.stackTrace: off.} to anonymous procs (They already don't appear in stacktrace)

* Fix failing tests in pragma category

Now check that the nim is a routine type first so we don't run into any assertion defects

* Hide stack trace pragma in docs and update doc tests

User doesn't need to know if something won't appear so this more becomes verbose noise

If this is a bad idea we can always add a `when defined(nimdoc)` switch so we don't add {.stackTrace: off.} to the Future[T] returning proc for docs
2022-12-15 16:05:34 +01:00
Jake Leahy
cbeefc877c Docs expand using parameters (#21076)
* Trying to fix by changing renderer

* add renderExpandUsing flag

This flag makes the renderer expand parameters that use using statement to have their full type

* Update docs

* Make comment better explain why checking for nkSym

* Fix nil access when macro/template has parameter with no type

* Fix nil access when node is not semmed yet
2022-12-12 07:44:17 +01:00
Andreas Rumpf
3812d91390 alternative, much simpler algorithm for strict func checking (#21066)
* alternative, much simpler algorithm for strict func checking

* forgot to git add new compiler module

* new spec is incredibly simple to describe

* fixes bigints regression

* typos

* closes #16305; closes #17387; closes #20863
2022-12-11 16:58:50 +01:00
metagn
5adfaa2a92 render post expr blocks better (#20871)
* render post expr blocks

* remove pointless diff

* fix PR split mistake
2022-11-22 20:40:05 +01:00
Andreas Rumpf
81087c949f fixes #20572 (#20585)
* fixes #20572

* added a test case
2022-10-17 23:48:51 +02:00
ringabout
0c0b086d58 fixes #20524; add forbids pragmas to hideable lists (#20525)
* fixes #20524; add forbids pragmas to hideable lists

* fixes nimdoc
2022-10-09 12:13:45 -04:00
Andreas Rumpf
0d23419e68 DAA and 'out' parameters (#20506)
* DAA and 'out' parameters

* progress

* documented strictDefs and out parameters

* docs, tests and a bugfix

* fixes silly regression
2022-10-06 17:08:41 +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
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
flywind
15ae9323e8 fix NimNode comment repr() regression [backport: 1.2] (#19726) 2022-04-25 11:19:21 +02:00
flywind
7f6e800caf move assertions out of system (#19599) 2022-03-23 20:34:53 +01:00
flywind
8bdb985395 fix wrong name (rnimsyn => renderer; pnimsyn => parser; scanner => lexer) (#18895)
* fix wrong module name

* rephrase more word
2021-09-25 13:22:00 +02:00
Timothee Cour
b24812df5f properly fix #10053 ; FieldDefect msg now shows discriminant value + lineinfo, in all backends (c,vm,js) (#11955)
* fix #10053 FieldError for vm

* fixup

* FieldError now also shows runtime value of discriminant

* fix field error reporting in vm

* also report culprit line info in err msg

* fix errors for newruntime 2

* fix for js

* fixup

* PRTEMP4

* works

* works

* works perfect

* refactor

* std/private/repr_impl

* suppport --gc:arc

* cleanup

* refactor

* simplify

* simplify

* simplify

* fixup

* move out compiler.vmgen.genCustom

* fixup

* fixup

* add tests

* revert compiler/debugutils.nim

* simplify reprDiscriminant

* fixup

* lib/std/private/repr_impl.nim -> lib/system/repr_impl.nim

* try to fix D20210812T165220

* honor --declaredlocs

* control toFileLineCol via --declaredlocs
2021-08-13 09:35:48 +02:00
Timothee Cour
488e9c2991 nim doc now correctly renders deprecated pragmas for routines and types (#18515) 2021-07-19 12:42:45 +02:00
Andreas Rumpf
f65f760dee fixes #15884 (#18230)
* fixes #15884

* micro optimization
2021-06-10 18:19:20 +02:00
flywind
68e522ecec Remove confusing <//> (#17830) 2021-04-26 09:04:52 +02:00
Timothee Cour
1b65b9cc19 refs #17292 fix repr: (discard) now does't render as discard which gave illegal code (#17455)
* refs #17292 fix `repr` with (discard)
* add tests
* add more tests
2021-04-16 14:55:51 +02:00
Timothee Cour
877cc5e4ff make repr handle setters foo= (#17683) 2021-04-09 09:37:10 +02:00
Timothee Cour
cce1b24b1c ast: add getPIdent (#17684)
* ast: add getPIdent

* fixup
2021-04-09 08:00:13 +02:00
Timothee Cour
4a11a04fba fix #14850: repr now correctly renders do (#17623)
* fix #14850: `repr` now correctly renders `do`

* add tests

* fix test
2021-04-03 16:05:37 +02:00
Timothee Cour
fe7a76f62f repr: fix rendering of 'big, =destroy etc (#17624) 2021-04-03 08:19:17 +02:00
Timothee Cour
a7bb973a24 docgen: render pragmas by default except for a select list (and fix #9074) (#17054) 2021-04-01 08:45:55 +02:00
Arne Döring
159c06e045 unify tuple expressions (#13793)
* unify tuple expressions

* fix test

* fix test

* apply feedback

* Handle empty tuples

* Fix rendering named unary tuple

* Protect static NimNode against stripping

* Slightly less hacky

* Revert "Slightly less hacky"

This reverts commit 170c5aec0addc029f637afbc948700ca006b7942.

* Slightly less hacky

* Cleanup

* Fix test

* Fix another test

* Add condsym

* Rebase fallout

* changelog: Move from compiler changes to language changes

* Add stricter tests

* Add empty tuple example to doc/astspec

* Fix test

Co-authored-by: Clyybber <darkmine956@gmail.com>
2021-03-30 02:06:51 +02:00
Andreas Rumpf
cfff27529e added nkError to the AST (#17567)
* added nkError to the AST

* Update lib/core/macros.nim

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

* Update compiler/ast.nim

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

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
2021-03-29 16:23:19 +02:00
Andreas Rumpf
5f5a92379f custom integer literals (#17489)
* user defined integer literals; refs #17020
* updated renderer.nim
* use mlexerutils helper
* imported all test cases from https://github.com/nim-lang/Nim/pull/17020
* final grammar updated
2021-03-24 14:46:19 +01:00
Timothee Cour
f3a6427109 refs #17292 fix repr with do: (#17449)
* refs #17292 fix `repr` with `do:`

* address comment
2021-03-23 08:34:04 +01:00