969 Commits

Author SHA1 Message Date
metagn
c694d8e4fd custom pragmas: correct error condition, remove outdated symkind whitelist (#21653)
* test not restricting custom pragma applied symbols

fixes #21652

* fix other test

* different patch

* fix tests

* actually test #18212 and other routines
2023-04-13 12:50:43 +02:00
ringabout
1ed54b7718 fixes #21632; enforce deref for wasMoved in ORC (#21647)
fixes #21632; enforce deref for `wasMoved`
2023-04-12 10:45:45 +02:00
metagn
f05387045d int64/uint64 as bigint in JS (#21613)
* int64/uint64 as bigint in JS

* fix CI

* convert to compile option

* fix lie

* smaller diff, changelog entry
2023-04-11 21:20:20 +02:00
Andrey Makarov
420b0c14eb Fix option lists with additional indentation in Markdown (#21633)
This is more Markdown-ish way to fix issue #21055, then PR #21625.
It does not enable RST definition lists, instead it makes
adding additional indentation (less than 4) right after a paragraph
be ignored, as it's done for all block elements in Markdown.
(In this case this tenet is applied to option lists that are not
part of CommonMark spec by themselves).
2023-04-11 06:40:20 +02:00
ringabout
5e016e4466 fixes #21638; fromJson should support empty objects (#21641)
* fixes #21638; `fromJson` should supports empty objects

* complete the logic
2023-04-11 06:38:30 +02:00
chmod222
31d3606fe8 fixes #21564; std/bitops: Add explicit type masking for the JS target (#21598)
* std/bitops: Add explicit type masking for the JS target

Typecasts on the JavaScript backend do not function the same way as they
do on C and C++ backends, so for bitwise operations we may need to mask them
back down into their allowed range when they get shifted outside it.

Since they do work as expected on the other backends, a default bitmask
of all 1's is casted down into the target type as an easily optimizable
"& 0xFF" operation for these backends.

* Fixup: this should still be a func

* Run test case on js target

* Adapt testcase to contributor guide and best practices

* Simplify constrain logic and turn into actual no-op for the C side
2023-04-03 05:22:31 +02:00
metagn
0630c649c6 disable google request in thttpclient (#21572)
was breaking macos CI
2023-03-28 16:34:30 +08:00
Eric N. Vander Weele
da7833c68b fixes #21538; expand len template parameter once in newSeqWith (#21543)
`len` could contain side effects and may result in different values when
substituted twice in the template expansion. Instead, capture the result
of substituting `len` once.

closes: #21538
2023-03-20 18:51:31 +01:00
Mark Leyva
285ea3c48e Fix: #21541. Add support for xnVerbatimText (#21542)
to text and text= procs. Remove unnecessary LF for xnVerbatimText
in $ proc.
2023-03-20 18:50:58 +01:00
ringabout
72e262666b fixes quoted variables with typedesc types (#21493) 2023-03-09 08:09:08 +01:00
ringabout
2d9af2bd55 closes #20704; add a test case (#21480) 2023-03-06 17:34:41 +08:00
ringabout
9948fed919 fixes #21326; fixes #7375; fixes #11986; fixes #9607; rework quote do; getAst uses type info to annotate the type of quoted variables; no more type erasures for quoted variables (#21433)
* fixes #21326; getAst uses type info to annotateType quoted variables

* simplify logics; sem types first

* fixes important packages

* add testcases

* tiny
2023-03-02 05:25:55 +01:00
Jake Leahy
6d423f1856 Make Time work with std/strformat (#21409)
* Add test case

* Remove formatValue template for `Time`

It didn't handle empty specifier correctly which caused it to be blank with strformat
2023-02-21 12:04:27 +01:00
c-blake
c91ef1a09f Fix closeHandle bug, add setFileSize, make resize work on Windows (#21375)
* Add general purpose `setFileSize` (unexported for now).  Use to simplify
`memfiles.open` as well as make robust (via hard allocation, not merely
`ftruncate` address space allocation) on systems with `posix_fallocate`.

As part of this, fix a bad `closeHandle` return check bug on Windows and
add `MemFile.resize` for Windows now that setFileSize makes that easier.

* Adapt existing test to exercise newly portable `MemFile.resize`.

* Since Apple has never provided `posix_fallocate`, provide a fallback.
This is presently written in terms of `ftruncate`, but it can be
improved to use `F_PREALLOCATE` instead, as mentioned in a comment.
2023-02-15 17:41:28 +01:00
c-blake
1d06c2b6cf This adds parseutils.parseSize, an inverse to strutils.formatSize (#21349)
* This adds `parseutils.parseSize`, an inverse to `strutils.formatSize`
which has existed since 2017.

It is useful for parsing the compiler's own output logs (like SuccessX)
or many other scenarios where "human readable" units have been chosen.
The doc comment and tests explain accepted syntax in detail.

Big units lead to small numbers, often with a fractional part, but we
parse into an `int64` since that is what `formatSize` stringifies and
this is an inverse over partial function slots.  Although metric
prefixes z & y for zettabyte & yottabyte are accepted, these will
saturate the result at `int64.high` unless the qualified number is a
small fraction.  This should not be much of a problem until such sizes
are common (at which point another overload with the parse result
either `float64` or `int128` could be added).

Tests avoids `test()` because of a weakly related static: test() failure
as mentioned in https://github.com/nim-lang/Nim/pull/21325. This is a
more elemental VM failure.  As such, it needs its own failure exhibition
issue that is a smaller test case.  (I am working on that, but unless
there is a burning need to `parseSize` at compile-time before run-time
it need not hold up this PR.)

* This worked with `int` but fails with `int64`.  Try for green tests.

* Lift 2-result matching into a `checkParseSize` template and format as a
table of input & 2 expected outputs which seems nicer and to address
https://github.com/nim-lang/Nim/pull/21349#pullrequestreview-1294407679

* Fix (probably) the i386 trouble by using `int64` consistently.

* Improve documentation by mentioning saturation.

* Improve documentation with `runnableExamples` and a little more detail in
the main doc comment based on excellent code review by @juancarlospaco:
https://github.com/nim-lang/Nim/pull/21349#pullrequestreview-1294564155

* Address some more @juancarlospaco code review concerns.

* Remove a stray space.

* Mention milli-bytes in docs to maybe help clarify why wild conventions
are so prone to going case-insensitive-metric.

* Add some parens.
2023-02-14 08:00:30 +01:00
ringabout
fc068ee06d fixes #18134; registers formatBiggestFloat in VM (#21299)
fixes #18134; registers formatBiggestFloat in vmops

strformat supports float format in VM
2023-01-26 23:03:59 +01:00
ringabout
c4d3d650ba fixes #21273; fixes an io.readLine off by one bug [backport 1.0] (#21276)
fixes #21273; io.readLine off by one
2023-01-25 14:56:19 -05:00
ringabout
5e7f7109e1 fixes #21290; deindent if the last same level is a text node (#21293)
* fixes #21290; deindent if the last same level is a text node

* add one more test
2023-01-24 13:35:19 +01:00
ringabout
b82b5d44af fixes #21278; deques.shrink off by one bug (#21284)
fixes #21278; deques.shrink off ny one bug
2023-01-20 11:43:45 +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
ringabout
a55604a3d8 fixes #21232; highlite.getNextToken() returns gtOperator for '/' in C (#21234) 2023-01-08 15:40:27 +01: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
9ba07edb2e build the documentation of official packages (#20986)
* remove db stuffs

* remove punycode

* remove

* fixes script

* add cloner

* patches

* disable

* patch

* fixes external packages

* disable two packages

* preview documentation build

* try again

* fixes URL

* fixes a bug

* simplify

* fixes documentaion

* fixes

* Apply suggestions from code review
2022-12-06 22:37:16 +08:00
ringabout
8266750497 [unittest] remove unnecessay export for testing (#20868) 2022-12-01 14:31:48 -05:00
Chavdar Ivanov
8f728ace35 Update tssl.nim (#20973)
This test hangs also under NetBSD and prevents the rest of the tests to carry over to the end.
2022-11-30 07:21:47 +08:00
Anna
b5a008bac8 Allow some tests to run without network (#20955)
* thttpclient.nim: respect NIM_TESTAMENT_REMOTE_NETWORKING

* tnetconnect.nim: respect NIM_TESTAMENT_REMOTE_NETWORKING
2022-11-29 06:40:28 +01:00
ringabout
27a38a9fce fix #13790; ptr char (+friends) should not implicitly convert to cstring (#20761)
* fix =#13790 ptr char (+friends) should not implicitly convert to cstring

* Apply suggestions from code review

* first round; compiles on windows

* nimPreviewSlimSystem

* conversion is unsafe, cast needed

* fixes more tests

* fixes asyncnet

* another try another error

* last one

* true

* one more

* why bugs didn't show at once

* add `nimPreviewCstringConversion` switch

* typo

Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
2022-11-24 07:49:23 +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
ringabout
0448f30fd9 fixes #20026; marks system procs which can raise defects (#20864)
* marks system procs which can raise defects

* add tests

* add more systemRaisesDefect

* add comment
2022-11-22 20:07:00 +01:00
ringabout
e03a178bff rename std/threads to std/typedthreads (#20850)
* rename `std/threads` to `std/oldthreads`

* fixes tests

* rename to `typedthreads`

* changelog
2022-11-16 16:35:20 +01:00
ringabout
06cd15663d fixes ptr to cstring warnings[backport] (#20848)
* fix =#13790 ptr char (+friends) should not implicitly convert to cstring

* Apply suggestions from code review

* first round; compiles on windows

* nimPreviewSlimSystem

* conversion is unsafe, cast needed

* fixes more tests

* fixes asyncnet

* another try another error

* last one

* true

* one more

* why bugs didn't show at once

* add `nimPreviewCstringConversion` switch

* typo

* fixes ptr to cstring warnings[backport]

* add fixes

Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
2022-11-16 10:22:51 +01:00
ringabout
cfab08d985 fixes tests and add notes (#20830) 2022-11-13 05:52:21 +01:00
ringabout
15bffc20ed fixes tests for quit (#20813)
Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
2022-11-11 12:01:35 +01:00
Vindaar
cc2b0f0172 [sugar] handle HiddenDeref in capture, error at CT if unsupported nnk (#20680)
* [sugar] handle HiddenDeref in capture, error at CT if unsupported nnk

Instead of running into trouble of the `.strVal` access failing, it's
better to error at CT.

* [tests] remove unnecessary import in test case

* improve ident extraction & extend test cases

* [tests] improve tests for `capture` of different types & act. check
2022-11-10 15:42:53 -05:00
Bung
10e7f18d01 remove compiler/strutils2.nim (#20748)
* use std strutils toLowerAscii char

* avoid additional call and assign

* remove compiler/strutils2.nim

* canonical
2022-11-05 12:22:45 +01:00
n5m
51bef9b4a8 fix posix.mq_receive compilation with cpp backend (#20710)
* fix posix.mq_receive compilation with cpp backend

* only enable runnableExample on posix

* linux, not posix

* simplify example

* add test

* mqueue.h does not exist on MacOS

* place test case in own block

* drop runnableExamples
2022-11-05 06:31:19 +01:00
n5m
52166e3546 allow deferred close of nil stream (#20706)
* allow deferred close of nil stream

* improve example
2022-10-31 11:20:06 +01:00
ringabout
e1ddd2d524 put std/threads under the umbrella of nimPreviewSlimSystem (#20711)
* put `std/threads` under the umbrella of `nimPreviewSlimSystem`

* add changelog

* fixes tests

* fixes tests again

* fixes tests
2022-10-31 06:36:50 +01:00
Andrey Makarov
779b1cc5be Fix #20628 for Windows (#20667)
* Fix #20628 for Windows

* Move isRegular - !isSpecial and onlyRegular - skipSpecial

* Forgot to change it in 1 more place
2022-10-28 10:01:28 +02:00
Andrey Makarov
8ed2431db0 Implement Unix file regularity check (#20448) (#20628)
* Implement Unix file regularity check

* update std/dirs also
2022-10-25 07:42:47 +02:00
Jason Beetham
ea0e45e62f Added 'openArray[char]' overloads to 'std/parseutils' (#20527)
* Added 'openarray[char]' overloads to 'std/parseutils'

* Removed redundant `start` and `last` params from slice using procs

* Fixed type for parseIdent overload

* fixed one by off with 'substr'

* removed missed start parameters for procedures

* Added 'openarray[char]' overloads to 'std/parseutils'

* Removed redundant `start` and `last` params from slice using procs

* Fixed type for parseIdent overload

* fixed one by off with 'substr'

* removed missed start parameters for procedures

* Fixed VM op to work with new 'opcSlice'

* Corrected captureBetween's logic to work with openarray

* js sys's parsefloat logic now uses openarray

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
2022-10-24 14:50:54 -04:00
ringabout
7c2aa53e44 fixes #19278; make privateAccess work with generic ref object (#20640)
* fixes #19278; make `privateAccess` work with generic ref object

* fixes
2022-10-24 15:24:51 +02:00
Jake Leahy
d261135c5c Fix tuple size check in std/jsonutils (#20637)
* Add test for tuple being invalid size

* Test tuple size before accessing fields

* Fix formatting for import

* Fix not being able to build from csources_v1

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2022-10-24 17:17:14 +08:00
Jake Leahy
69cb671d8d Pass json options to hooks (#20638)
* Added tests

* Fix expected string

* Allow hooks to take an optional parameter that is the current options

* Add options to hooks for other generic types

* Fix doc links
2022-10-24 08:14:17 +02:00
ringabout
9361938ccd add std/appdirs (#20618) 2022-10-22 13:42:46 +02:00
ringabout
3c12b72168 add typesafe std/paths, std/files, std/dirs, std/symlinks (#20582)
* split std/os; add typesafe std/paths
* add more files, dirs, paths
* add documentation
* add testcase
* remove tryRemoveFile
* clean up
* Delete test.nim
* apply changes
* add `add` and fixes
2022-10-21 21:53:44 +02:00
ringabout
b07526b2c7 refactor envvars, oserrors; register vmops (#20592)
* refactor envvars, oserrors; register vmops

* remove type definitions
2022-10-18 19:44:26 +02:00
ringabout
1e15f975b8 fixes #19162; enable strictEffects for v2 (#19380)
* enable stricteffects
* add gcsafe
* fix tests
* use func
* fixes pegs tests
* explicitly mark repr related procs with noSideEffect
* add nimLegacyEffects
* change URL
* fixes docopt
* add `raises: []` to repr
* fixes weave
* fixes nimyaml
* fixes glob
* fixes parsetoml
* Apply suggestions from code review
* Update testament/important_packages.nim
* add legacy:laxEffects
2022-10-15 14:07:40 +02:00
ringabout
13b3ea71da oids sticks to 24 length strings; fixes breaking changes (#20546)
oids sticks 24 length strings
2022-10-12 15:15:21 +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