Commit Graph

829 Commits

Author SHA1 Message Date
Andrey Makarov
162b07d72c fix parsesql.treeRepr when nil is in input (#18974)
* fix parsesql.treeRepr when nil is in input

* return newNode(nkNone) as default value, not nil
2021-10-17 05:38:07 +02:00
ee7
3b1a601fe1 sequtils: fix errors from strictFuncs use (#18998)
Nim 1.4.x compiled the below code without error when using
`--experimental:strictFuncs`

    import std/sequtils

    type Foo = ref object

    let foo1 = Foo()
    let foo2 = Foo()
    let foos = @[foo1, foo2]
    let fooTuples = @[(foo1, 1), (foo2, 2)]

    discard repeat(foo1, 3)
    discard zip(foos, foos)
    discard unzip(fooTuples)

However, since 2020-12-09, devel Nim produced errors like

    /tmp/bar.nim(11, 15) template/generic instantiation of `repeat` from here
    /foo/nim/pure/collections/sequtils.nim(172, 6) Error: 'repeat' can have side effects
    an object reachable from 'x' is potentially mutated
    /foo/nim/pure/collections/sequtils.nim(183, 15) the mutation is here
    /foo/nim/pure/collections/sequtils.nim(183, 15) is the statement that connected the mutation to the parameter

This commit reverts some `proc` to `func` changes so that code that:

- calls `repeat`, `zip`, or `unzip`
- and instantiates them with types containing `ref`

can once again be compiled with `strictFuncs`. Otherwise, a user might
be forced to drop or alter their `strictFuncs` use when upgrading from
Nim 1.4.x, or when writing new code that uses these procedures (at least
for now, with the current `strictFuncs` implementation).

This commit also adds tests to assert that the remaining funcs in this
module can be compiled with `strictFuncs` when used with types
containing `ref`.

The original batch of `proc` to `func` changes in `sequtils.nim` was in
commit 6f57ebae34, which was partially reverted in 38eb021f81.

See also: https://github.com/nim-lang/Nim/issues/16305
2021-10-16 11:25:05 +02:00
Andrey Makarov
f03872d99e rst: minor fixes (#18960) 2021-10-06 13:53:01 +02:00
flywind
e7bac91773 rename nimEnableHashRef [backport] (#18941)
* rename nimEnableHashRef [backport]
* Apply suggestions from code review

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
2021-10-04 21:28:13 +02:00
quantimnot
f017eadc97 Add support for strictEffects to std/pegs (#18949)
* Add support for `strictEffects` to `std/pegs`

* Fixed support of older Nim versions

Co-authored-by: quantimnot <quantimnot@users.noreply.github.com>
2021-10-04 21:27:13 +02:00
Timothee Cour
f061971a9b envPairs works in vm, nims (#18615)
* envPairs works in vm, nims

* fixup
2021-09-29 09:32:39 +02:00
flywind
ee9795f76f fix #18844 (#18851) 2021-09-20 09:50:20 +02:00
flywind
b3ad68edea remove channels (#18801)
* remove channels

* test
2021-09-04 15:57:02 +02:00
Andreas Rumpf
69cabaa81c sequtils now support strict effect tracking (#18782) 2021-09-02 14:35:25 +02:00
Tomohiro
7c8ea490a2 Fix initrand to avoid random number sequences overlapping (#18744)
* Fix initrand to avoid random number sequences overlapping

* Minor fix

* Fix compile error on js backend

* Disable new test for js backend

* Minor fix

* tempfiles module uses random.initRand()

* Remove unused module import from lib/std/tempfiles.nim

* Initialize baseState in initRand()

* Run tests/stdlib/trandom.nim from tests/test_nimscript.nims

* baseState is initialized only with sysrand.urandom and quit if failed

* Add comments
2021-09-02 14:12:14 +02:00
Andreas Rumpf
e0ef859130 strict effects (#18777)
* fixes #17369
* megatest is green for --cpu:arm64
* docgen output includes more tags/raises
* implemented 'effectsOf' 
* algorithm.nim: uses new effectsOf annotation
* closes #18376
* closes #17475
* closes #13905
* allow effectsOf: [a, b]
* added a test case
* parameters that are not ours cannot be declared as .effectsOf
* documentation
* manual: added the 'sort' example
* bootstrap with the new better options
2021-09-02 12:10:14 +02:00
flywind
72fa5833ad fix #9778 (pairs iterator calling a helper proc with tuple return type will cut the iterator yield into half) (#18767)
* test someSymFromImportTable
* Update compiler/lookups.nim
* test nkTupleConstr
* use isConstExpr
* add tests
* add comments and todo
* use todo
2021-09-02 07:41:14 +02:00
konsumlamm
2d84f6e7c8 Fix #18718 (#18731)
Update tests
2021-08-23 00:13:39 +02:00
Tomohiro
373bbd9bb4 Add ceilDiv to math (#18596)
* Use assert in runnableExamples and improve boundary check
* Add more tests for ceilDiv
* Fix comment in ceilDiv
* Calling ceilDiv with int type T such like sizeof(T) > 8 is error
2021-08-19 11:35:40 +02:00
flywind
901c5ded52 fix #18702(fix parseutils.parseFloat) (#18703) [backport:1.0]
* fix #18702
* Apply suggestions from code review
2021-08-16 15:14:35 +02:00
flywind
f559319a68 fix a sqlite bug (#18669) 2021-08-12 09:21:01 -07:00
Timothee Cour
5c1304a418 fix #18670 quoteShellCommand, quoteShell, quoteShellWindows on windows (#18671) 2021-08-12 16:50:08 +02:00
Timothee Cour
6c1bd4bb1c fix: var a{.foo.} = expr inside templates (refs #15920) (except when foo is overloaded) (#13869)
* fix: `var a{.foo.} = expr` inside templates
* add test
* improve tdecls test
* improve tests
* add failing test
* PRTEMP
* fixup
2021-08-11 12:17:17 +02:00
Christian Ulrich
0d3af5454b Only allow IPv4 literals in strict form (#18656)
* Only allow IPv4 literals in strict form

The strict form as defined in RFC 6943, section 3.1.1 only allows the dotted
form ddd.ddd.ddd.ddd of IPv4 literals, where ddd is a one to three digit decimal
number between 0 and 255. Until now octal numbers (with a leading zero) were
interpreted as decimal numbers which has security implications, see
CVE-2021-29922 and CVE-2021-29923.

* Update lib/pure/net.nim

Co-authored-by: Dominik Picheta <dominikpicheta@googlemail.com>
2021-08-08 19:11:07 +01:00
Timothee Cour
6b3c77e7f4 Remove tracking of environment from osenv.nim v2 (#18575)
* Remove unnecessary environment tracking

* try to fix windows

* fix delEnv

* make putEnv work on windows even with empty values; improve tests: add tests, add js, vm testing

* [skip ci] fix changelog

Co-authored-by: Caden Haustein <code@brightlysalty.33mail.com>
2021-07-29 23:05:26 +02:00
Miran
e616675c41 various small documentation improvements (#18602) 2021-07-28 14:31:13 +02:00
Timothee Cour
8d2f6bba3a support same-line doc comments in routines (#18595)
* support same-line comments in routines
* remove assert as per review comment
2021-07-27 19:50:59 +02:00
Andreas Rumpf
fa0209609d fixes #18565 (#18593)
* fixes #18565
2021-07-27 09:36:19 +02:00
Timothee Cour
5f7db65257 followup #18453 (#18582) 2021-07-25 12:55:33 -07:00
Timothee Cour
76f74fae88 std/random: fix overflow bugs; fixes #16360; fixes #16296; fixes #17670 (#18456) 2021-07-23 13:41:16 +02:00
Caden Haustein
f62f4159f8 Replace calls to putenv with setenv (#18530)
* Replace calls to C `putenv` with C `setenv` to remove possible memory leaks

* Add test of correct behaviour on invalid input

* Fix style in tests/stdlib/tos.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* Update tests/stdlib/tos.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* Update tests/stdlib/tos.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* Add comment with bug number to tests/stdlib/tos.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* Fix possible msvc arch issues

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
2021-07-23 10:04:29 +02:00
Timothee Cour
cf0cf32d27 make -d:nimFpRoundtrips work consistently in vm vs rt, fix #18400, etc (#18531)
* compiler/vmhooks: add getVar to allow vmops with var params
* addFloat vmops with var param
* cgen now renders float32 literals in c backend using roundtrip float to string
2021-07-20 22:13:52 +02:00
Andrey Makarov
8c7ee96457 rst: add missing line/column info for some warnings (#18383)
* rst: add missing line/column info for some warnings

* add workaround

* use TLineInfo/FileIndex for storing file names

* fix blank lines in include file (rm harmful strip)

* don't use ref TLineInfo

* return `hasToc` as output parameter for uniformity

* Update compiler/docgen.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* Update compiler/docgen.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* Update lib/packages/docutils/rst.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* address review - stylistic things

* Update compiler/docgen.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* unify RST warnings/errors names

* doAssert + minor name change

* fix a bug caught by doAssert

* apply strbasics.strip to final HTML/Latex

* rm redundant filename

* fix test after rebase

* delete `order` from rnFootnoteRef,

also display errors/warnings properly when footnote references are from
different files

* Update compiler/lineinfos.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* Update lib/packages/docutils/rstast.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* Update lib/packages/docutils/rstast.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* Update lib/packages/docutils/rstast.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* revert because of error:

Error: cannot prove that it's safe to initialize 'info' with the runtime value for the discriminator 'kind'

* Update lib/packages/docutils/rstgen.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* apply suggestion

* Update lib/packages/docutils/rst.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* add Table for string->file name mapping

* do not import compiler/lineinfos

* fix ambiguous calls

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
Co-authored-by: narimiran <narimiran@disroot.org>
2021-07-20 08:32:22 +02:00
flywind
bdfee32dc8 close #18489 (#18524) 2021-07-19 12:43:31 +02:00
Andreas Rumpf
99c4b69097 fixed system.delete (#18507) 2021-07-18 15:16:26 +02:00
Timothee Cour
adba5eb45e deprecate strutils.delete and add an overload with saner semantics consistent with sequtils.delete; follows #18487 (#18510) 2021-07-18 11:10:08 +02:00
Miran
8091545f95 Revert #17398 and #17402 (#18480)
* Revert "followup #17398: `getTempDir`, `getConfigDir` now do not have trailing DirSep (#17402)"

This reverts commit 2356d0603f.

* Revert "fix #17393 getHomeDir and expandTilde should not include trailing `/` (#17398)"

This reverts commit bebf2ce24a.

* fix test
2021-07-18 11:04:19 +02:00
Timothee Cour
923a1c6ea7 fix nativeToUnixPath (#18501) 2021-07-17 07:54:47 +02:00
Andreas Rumpf
25efb53862 make dragonbox opt-in via -d:nimFpRoundtrips (#18504)
* make dragonbox opt-in via -d:nimFpRoundtrips

* make tests green again

* make tests green again
2021-07-16 18:29:49 +02:00
Andreas Rumpf
96a7f9b31c deprecate cuchar, don't redefine it (#18505) 2021-07-16 15:50:02 +02:00
Ivan Bobev
5e6680406f Add changes required by Nimble lock file support (#12104)
Implemented support for Nimble local cache with package directories with
a checksum of the package at the end of their names. Now the compiler
supports package paths in the form:

 * /path_to_nimble_cache_dir/pkgs/package_name-1.2.3-
FEBADEAEA2345E777F0F6F8433F7F0A52EDD5D1B

 * /path_to_nimble_cache_dir/pkgs/package_name-#head-
042D4BE2B90ED0672E717D71850ABDB0A2D19CD2

 * /path_to_nimble_cache_dir/pkgs/package_name-#branch-name-
DBC1F902CB79946E990E38AF51F0BAD36ACFABD9

Related to nim-lang/nimble#127
2021-07-15 22:13:01 +02:00
Timothee Cour
1d6863a789 deprecate sequtils.delete and add an overload with saner semantics consistent with system.delete (#18487)
* deprecate sequtils.delete and add an overload with saner semantics
* AssertionDefect => IndexDefect
* improve tsequtils
* add tests; use splice in js for optimization
2021-07-15 20:54:07 +02:00
flywind
1b128ac045 close #17986 add testcase (#18477) 2021-07-12 18:18:07 -04:00
Andrey Makarov
0e44d137f9 rm redundant blank lines before literal blocks (#18465) 2021-07-08 20:24:57 -04:00
Aditya Siram
2d758795f0 Rename test variable due to unfortunate connotations (#18453) 2021-07-08 10:21:30 +08:00
Timothee Cour
d1447fe25d major improvements to std/wrapnils: optimal codegen, case objects, lvalue semantics (#18435)
* wrapnils now generates optimal code; also handles case objects
* changelog
* unsafeAddr => addr
2021-07-07 06:04:36 +02:00
pyautogui
927a832dde deprecate std/mersenne (#18395)
Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2021-07-05 10:12:58 -07:00
Mark Pointing
17911a116d Removed hard coded ports from thttpclient_standalone.nim. (#18374)
Co-authored-by: Dominik Picheta <dominikpicheta@googlemail.com>
Co-authored-by: Mark Pointing <mark@futurepoint.com.au>
Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
2021-06-30 10:22:38 -07:00
Clyybber
6e74fecb42 Simplify addInt, remove digits10 (#18356)
* Simplify addInt, remove digits10

Co-authored-by: Charles Blake <charlechaud@gmail.com>

* Fix bootstrapping

* Add noInit to tmp array

* noInit -> noinit

Co-authored-by: Charles Blake <charlechaud@gmail.com>
2021-06-28 15:00:14 +02:00
gemath
e720bbdd76 Peg captures get stack-like behavior (#18369)
* Implements reverse capture indexing.
* Now works for modified backrefs too.
* Changed reverse indexing syntax prefix for back-references to '$^'.
2021-06-28 12:33:20 +02:00
Andrey Makarov
1b9b806007 rst: fix bug 20 from #17340 (#18360)
and a leftover bug: priority of option list inside definition list
2021-06-26 18:10:46 +02:00
Timothee Cour
565e07a993 enable VM tracing in user code via {.define(nimVmTrace).} (#18244)
* enable VM tracing in user code via  `{.define(nimVmTrace).}`

* add vmutils.vmTrace

* add vmTrace
2021-06-24 11:55:31 +02:00
Andrey Makarov
0c8d3ae985 rst: allow comment to continue on second line (#18338) 2021-06-24 10:28:28 +02:00
Andrey Makarov
9c43f05099 Markdown: allow to end URL with balanced parenthesis (#18321)
* Markdown: allow to end URL with balanced parenthesis

* Update lib/packages/docutils/rst.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* apply suggestion

* remove unnecessary if

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
2021-06-23 07:50:05 +02:00
Timothee Cour
5badeea170 followup #18318: simplify dollarImpl and add a test (#18330) 2021-06-22 21:42:39 -07:00