5433 Commits

Author SHA1 Message Date
Miran
48c62ca48b [backport:1.0] json: limit recursion depth (#19252)
* json: limit recursion depth

* do not run this check for JS backend

(cherry picked from commit c17baaefbc)
2021-12-14 18:19:08 +01:00
Ștefan Talpalaru
a2f5e98baa nimRawSetjmp: support Windows (#19197)
* nimRawSetjmp: support Windows

Using `_setjmp()` directly is required to avoid some rare (but very
annoying) exception-related stack corruption leading to segfaults on
Windows, with Mingw-w64 and SEH.
More details: https://github.com/status-im/nimbus-eth2/issues/3121

Also add "nimBuiltinSetjmp" - mostly for benchmarking.

* fix for Apple's Clang++

(cherry picked from commit 69aabdab80)
2021-12-11 05:47:32 +01:00
Andreas Rumpf
46275126b8 fixes a possible 'javascript:' protocol exploit [backport:1.0] (#19134)
* fixes a possible 'javascript:' protocol exploit [backport:1.0]

* add tests

* Update tests/stdlib/trstgen.nim

* add the same logic for hyperlinks

* move the logic into a proc

Co-authored-by: narimiran <narimiran@disroot.org>
(cherry picked from commit 9338aa2497)
2021-12-10 11:47:06 +01:00
Andreas Rumpf
ac57c3193d fixes an old ARC bug: the produced copy/sink operations don't copy the hidden type field for objects with enabled inheritance; fixes #19205 [backport:1.6] (#19232)
(cherry picked from commit 32d4bf3525)
2021-12-10 11:46:35 +01:00
Andreas Rumpf
7cf5e73fb7 fixes a converter handling regression that caused private converters to leak into client modules; fixes #19213; [backport:1.6] (#19229)
(cherry picked from commit 502ac4ed5e)
2021-12-10 11:46:26 +01:00
Etan Kissling
ee876aee28 allow HSlice bounded by constants of distinct types (#19219) [backport:1.2]
When creating heterogenous slices of distinct types, the compiler does
not initialize the internal type's `size` before accessing it.
This then leads to this crash message:
```
compiler/int128.nim(594, 11) `false` masking only implemented for 1, 2, 4 and 8 bytes [AssertionError]
```
This patch initializes the `size` properly, fixing the problem.

(cherry picked from commit 0213c7313b)
2021-12-08 08:32:57 +01:00
Andreas Rumpf
8ed903d1d0 fixes #19159 [backport:1.6] (#19210)
(cherry picked from commit 1cbdc1573a)
2021-12-06 11:19:26 +01:00
Andreas Rumpf
bfa8188dac fixes #19198 [backport:1.6] (#19209)
* fixes #19198 [backport:1.6]

* added a test case

(cherry picked from commit f90620fb32)
2021-12-06 11:19:17 +01:00
Andreas Rumpf
56409c15c0 fixes #19015 [backport:1.6] (#19204)
(cherry picked from commit d584dd5b99)
2021-12-06 11:19:08 +01:00
flywind
1247043c90 fix marshal bugs in VM (#19161) [backport:1.6]
(cherry picked from commit fe46c8b5f1)
2021-11-22 16:30:41 +01:00
Andreas Rumpf
167881bb83 fixes #19051 [backport:1.6] (#19133)
(cherry picked from commit c6fc3b2eae)
2021-11-17 09:26:08 +01:00
Andreas Rumpf
f85e09633d fixes #19013 [backport:1.6] (#19111)
* fixes #19013 [backport:1.6]

* added test case

(cherry picked from commit b7c66ce860)
2021-11-11 16:16:03 +01:00
Andreas Rumpf
575450dfec fixes another effect inference bug [backport:1.6] (#19100)
* fixes another effect inference bug [backport:1.6]

(cherry picked from commit fce89cb60a)
2021-11-11 16:15:51 +01:00
flywind
233c6e9fb3 fix #18410 (Errors initializing an object of RootObj with the C++ backend) [backport] (#18836)
* fix #18410

* one line comment

* typo

* typo

* cover cpp

(cherry picked from commit 2f730afe9e)
2021-11-03 15:06:31 +01:00
Derek 呆
97286db546 fix #18971 (#19070) [backport:1.6]
since the example code return value from global variable, instead
of first argument, the `n.len` is 1 which causes compiler crashes.

(cherry picked from commit f755e452d2)
2021-11-03 15:06:24 +01:00
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
Miran
8a4eeba218 try to fix broken ssl test (#18991) 2021-10-14 09:56:58 +02:00
Dominik Picheta
2aa97a228a Removes deprecated {.injectStmt.}. Fixes #18666 (#18984) 2021-10-13 11:09:45 +02:00
Andreas Rumpf
6f15af41a7 fixes a regression caused by overloadable enums even though they're opt-in (#18970) 2021-10-07 15:07:24 +02:00
quantimnot
19774a72e7 Fixed strictFuncs support for std/pegs (#18951)
* Fixed `strictFuncs` support for `std/pegs`

Enabled `std/pegs` in the `strictFuncs` import test.

Fixes #18057
Fixes #16892
See #18111

* Rebased from `devel`

* Conditionally compile `std/pegs` in `koch`

This is for supporting `csources` bootstrap.

Co-authored-by: quantimnot <quantimnot@users.noreply.github.com>
2021-10-07 12:16:58 +02:00
Andrey Makarov
f03872d99e rst: minor fixes (#18960) 2021-10-06 13:53:01 +02:00
flywind
cb30dc5170 enable tests for #2710 (#18961) 2021-10-06 09:42:35 +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
flywind
5c4692fad4 rename nimLegacyJsonutilsHoleyEnum [backport] (#18938)
* enable nimPreviewJsonutilsHoleyEnum [backport]

* docuement nimPreviewJsonutilsHoleyEnum
2021-10-01 20:26:29 +02:00
flywind
4b764f4c7c close #17319; add testcase (#18934) 2021-10-01 16:19:02 +08:00
flywind
677969f6ea alternative to #18918 (#18927)
* fix #16558

* add testcase
2021-09-30 16:57:06 +02:00
Jason Beetham
f915b3aa86 Alternative to #18928 (#18931)
* fixed #18841

* Added test
2021-09-30 16:55:43 +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
Andreas Rumpf
576fece909 fixes 'lent T' inside object constructor [backport] (#18911)
* fixes 'lent T' inside object constructor [backport]

* progress
2021-09-27 22:23:31 +02:00
Andreas Rumpf
7e5eab571e closes #18690; make view types stricter [backport] (#18891)
* closes #18690

* don't allow capturing of view types [backport]
2021-09-24 16:27:34 +02:00
Andreas Rumpf
90a2b5afd8 correct effect tracking for .borrowed procs [backport] (#18882)
* correct effect tracking for .borrowed procs [backport]

* progress

* fix error message in a test

* correctly fix it

Co-authored-by: narimiran <narimiran@disroot.org>
2021-09-23 16:47:24 +02:00
Andreas Rumpf
6163bdd279 closes #16132 [backport] (#18880)
* closes #16132 [backport]

* fixes #16132 [backport]
2021-09-22 15:07:36 +02:00
flywind
ee9795f76f fix #18844 (#18851) 2021-09-20 09:50:20 +02:00
Andreas Rumpf
c56ba3f06a fixes #18847 [backport] (#18870) 2021-09-20 09:09:53 +02:00
Andreas Rumpf
3241df2a13 fixes #18858 [backport] (#18868)
* fixes #18858 [backport]

* ensure async tests work with --experimental:strictEffects [backport]

* ensure async tests work with --experimental:strictEffects [backport]
2021-09-19 23:35:50 +02:00
alaviss
6cd219c3a3 semtypinst: don't wrap type nodes from expressions in static[T] (#18860) 2021-09-17 06:51:26 +02:00
Jason Beetham
f8e185fec0 Fixed borrowing dot from aliases (#18854) 2021-09-16 08:48:58 +02:00
flywind
cebf7cdc1e fix #10128 (#18852) 2021-09-14 19:40:42 +02:00
flywind
bf1700bab1 add testcase for #7308 (#18849) 2021-09-14 19:39:55 +02:00
Jason Beetham
172253cb55 Dotborrow now works with generic distincts (#18848) 2021-09-14 19:34:52 +02:00
Jason Beetham
3f3e0fa303 Fixed #18838 (#18841) [backport] 2021-09-13 09:35:19 +02:00
Jason Beetham
5d1608c976 Generic pointer procs now error if no types supplied (#18832)
* more precise logic for pointer procs

* added test for generic pointer procs

* Fixed generic getting bracket expr if erroring
2021-09-11 22:20:22 +02:00
Jason Beetham
66e53bdd7b Fixed type inference for 'set` and 'tuple' (#18827)
* improved built in typeclass inference

* Smarter logic to fit node

* Forgot the untyped check
2021-09-11 13:05:53 +02:00
flywind
c56008450a fix CI failure(upstream changes) (#18820)
* fix upstream changes

* Update tests/js/tunittest_error2.nim

Co-authored-by: flywind <xzsflywind@gmail.com>

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2021-09-08 11:47:14 +02:00
Jason Beetham
ee2eb5cae2 Fix subranges of distinct types (#18816) [backport] 2021-09-07 17:11:08 +02:00
Jason Beetham
30d28bcefc Fixes implicit and explicit generics in procedures (#18808)
* Fixes implicit and explicit generics

* moved block logic into 'maybeInstantiateGeneric'

* Added more tests

* Update compiler/semexprs.nim

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2021-09-06 20:11:21 +02:00
Andreas Rumpf
34a53e8049 fixes #12642 (#18811)
* fixes #12642

* update important packages; refs #18804

* fixes #18805; refs #18806

* fixes a regression

* Update testament/categories.nim

Co-authored-by: flywind <xzsflywind@gmail.com>

* progress

* progress

Co-authored-by: flywind <xzsflywind@gmail.com>
2021-09-06 17:43:03 +02:00
Jason Beetham
90bfd34250 '[]' can now be used for iterators (#18814) 2021-09-06 15:30:49 +02:00