Commit Graph

212 Commits

Author SHA1 Message Date
Andreas Rumpf
f90620fb32 fixes #19198 [backport:1.6] (#19209)
* fixes #19198 [backport:1.6]

* added a test case
2021-12-04 07:43:20 +01:00
Timothee Cour
5f7db65257 followup #18453 (#18582) 2021-07-25 12:55:33 -07:00
Jason Beetham
5386ae75ba Fixed template const tuple unpacking (#18562) 2021-07-23 08:46:13 +02:00
Timothee Cour
ad70a65e0e fix #18310 system.== in vm for NimNode (#18313)
* fix #18310 == in vm

* fixup

* fixup
2021-06-21 09:46:31 +02:00
Timothee Cour
6ab911accb fix tests/vm/tcastint.nim which used non-sensical when defined nimVM (and contained wrong tests) (#17954) 2021-05-08 00:27:06 +02:00
Timothee Cour
00bb3c779e fix https://github.com/timotheecour/Nim/issues/718: CompileTime is not cached apparently (#17940) 2021-05-05 08:41:53 +02:00
Timothee Cour
938c6ac5df add logging to help investigate why tests/vm/tconst.nim is flaky (#17934) 2021-05-04 00:50:06 -07:00
Timothee Cour
78e2d299df typo: nonexistant => nonexistent (#17918)
* typo: nonexistant => nonexistent

* fix test (ordering differs because of https://github.com/nim-lang/Nim/issues/17910)
2021-05-02 00:26:41 +02:00
Timothee Cour
82996aee3f misc fixes: remove forceConst (obsolete by static), add more runnableExamples to system (#17896)
* misc fixes

* add runnableExamples for compileOption

* add runnableExamples for runnableExamples

* move tconsteval => tconst

* cleanup
2021-05-01 07:26:52 +02:00
flywind
5c12c711f7 follow up #17518 (#17726) 2021-04-15 19:25:35 +02:00
flywind
70a30317f7 fix #16693: testament spec nimout too lax (#16698)
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
2021-04-04 13:47:28 -07:00
flywind
a5600e49df close #9622 add testcase (#17557)
* fix nim js cmp fails at CT

* close #9622 add testcase
2021-03-29 01:40:37 +02:00
flywind
42e895feb1 close #15696 (#17518) 2021-03-25 21:20:58 -07:00
Timothee Cour
0cb02fbbee add overload add(a: var string, b: openArray[char]) (#15951)
Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2021-03-01 07:51:12 -08:00
Saem Ghani
7c2ac98880 Fixes #17039 - ldObj checks node/nodeAddr access (#17123)
Checked field expressions, such as an object variant field access results in
occasionally broken address analysis crashing the VM. This guard added here
mimics guarded access in ldObjAddr as well. This is to prevent a crash, while a
fix is devised.
2021-02-23 09:02:06 +01:00
Timothee Cour
cde950e1bc make copySign for js consistent with other backends (#16609)
* make copySign work more robustly in js
* improve tests
* improve tests/vm/tcastint.nim
2021-02-22 08:47:00 +01:00
Timothee Cour
4326f743d0 compilesettings: add libpath (#16997)
* compilesettings: add libpath

* add test

* changelog

* fixup

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2021-02-12 23:50:41 +01:00
Timothee Cour
c17cad0992 close #8015: const array indexing zeroes data in object variants at runtime (#16782) 2021-01-21 11:11:42 +01:00
Timothee Cour
0d0e43469f fix #14340 (#16386) 2021-01-01 22:55:22 +01:00
flywind
6d442a40a6 use doAssert in tests (#16486) 2020-12-28 14:13:21 +01:00
Timothee Cour
bc84d9c8cb [backport => 1.0] fix #16428 vmops now works for generic procs (#16429)
* fix #16428 vmops now works for generic procs

* remove duplication
2020-12-22 02:05:21 +01:00
Andreas Rumpf
d306a04466 fixes #16069; [backport:1.2] [backport:1.4] (#16115)
* fixes #16069; refs https://github.com/nim-lang/RFCs/issues/257 [backport:1.2] [backport:1.4]

* make tests green again
2020-11-24 16:09:00 +01:00
Timothee Cour
b3c3557c33 fix #16025 repr now consistent: does not insert trailing newline (#16034) 2020-11-19 12:12:51 -08:00
Andrey R (cooldome)
632af8afad Revert "follow #16009 VM supports cast nil to ptr (#16012)"
This reverts commit fec19c980e.
2020-11-17 18:54:33 +00:00
flywind
fec19c980e follow #16009 VM supports cast nil to ptr (#16012)
* follow #16009 VM supports cast nil to ptr

* more testcase
2020-11-17 10:47:01 +00:00
flywind
203bddf307 close #11637(add testcase for #11637) (#15879)
* close #11637(add testcase for #11637)

* Update tests/vm/t11637.nim
2020-11-08 11:02:12 +08:00
flywind
a8af664e8b fix #15463 (#15831) 2020-11-05 14:00:08 +01:00
flywind
5b4c17b5e7 Closure iterators are not supported by VM (#15818) 2020-11-02 10:58:14 +01:00
flywind
558115fa29 fixes #15717 2020-11-02 10:27:48 +01:00
Timothee Cour
3bdc000521 [backport] fix #15595 procvar == works in VM (#15724) 2020-10-26 22:19:05 +02:00
Timothee Cour
d4c2e2c53f fix #15704 #15597 wrong VM register was freed (#15705)
* fix #15704 #15597 wrong VM register was freed

* same treatment for nkCheckedFieldExpr

* note concerning HighRegisterPressure

* bump NimPatch

* Update lib/system.nim

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2020-10-26 09:13:37 +01:00
Timothee Cour
bf894ad3eb close #8007 (#15695) 2020-10-23 23:16:47 +02:00
cooldome
ae320b4e7d fix #15662 (#15678)
* fix #15662

* alternative fix

* fix spacing
2020-10-23 11:14:54 +02:00
Danil Yarantsev
d22ab0fb96 Add tests to #15363 (#15633) 2020-10-19 13:16:56 +02:00
Timothee Cour
8a5f550491 followup after #15529 and #15534 (#15536) 2020-10-10 07:05:27 +02:00
Timothee Cour
8fb57d7451 close #13081 (#15529)
* close #13081

* fixup
2020-10-09 08:56:09 +02:00
Miran
e7f280bd26 Remove deprecated stuff from stdlib (#14699)
* update to the latest Jester

* remove deprecated procs from some stdlib modules

* 'criterion' is not maintained anymore and relies on obsolete stuff
2020-06-17 15:25:02 +02:00
Timothee Cour
9502e39b63 nim doc --backend:js, nim doc --doccmd:-d:foo, nim r --backend:js, --doccmd:skip + other improvements (#14278)
* `nim doc --backend:js|cpp...`
`nim doc --doccmd:'-d:foo --threads:on'`
`nim r --backend:cpp...` (implies --run --usenimcache)
* --usenimcache works with all targets
* --docCmd:skip now skips compiling snippets; 50X speedup for doc/manual.rst
2020-05-11 12:01:18 +02:00
alaviss
83435fe696 tslow_tables: wait for an additional 2 seconds (#14266)
This test runtime tends to hover around the 5s mark depending on how
loaded the system currently is. This causes the test to fail a lot
during CI, per analytics:
https://dev.azure.com/nim-lang/Nim/_test/analytics?definitionId=1&contextType=build

Give the test an extra 2 seconds to account for unrelated overhead.
2020-05-07 22:07:08 +02:00
Timothee Cour
330b3c4453 fix regression: -d:nimHasLibFFI was not being tested anymore (#14234)
* * fix regression: -d:nimHasLibFFI was not being tested anymore,
in part because testament was silently treating some errors as easy to overlook messages
* turned that message into an error
* -d:nimHasLibFFI is now being tested with nim cpp
* use correct signatures for importc procs
* workaround for openbsd to unblock ctffi testing
2020-05-06 17:16:54 +02:00
hlaaftana
9b01c6cf48 discardable async procs are now an error (#14176)
* add discard warning in manual
2020-05-01 09:49:13 +02:00
c-blake
a0b33f9408 Add hashWangYi1 (#13823)
* Unwind just the "pseudorandom probing" (whole hash-code-keyed variable
stride double hashing) part of recent sets & tables changes (which has
still been causing bugs over a month later (e.g., two days ago
https://github.com/nim-lang/Nim/issues/13794) as well as still having
several "figure this out" implementation question comments in them (see
just diffs of this PR).

This topic has been discussed in many places:
  https://github.com/nim-lang/Nim/issues/13393
  https://github.com/nim-lang/Nim/pull/13418
  https://github.com/nim-lang/Nim/pull/13440
  https://github.com/nim-lang/Nim/issues/13794

Alternative/non-mandatory stronger integer hashes (or vice-versa opt-in
identity hashes) are a better solution that is more general (no illusion
of one hard-coded sequence solving all problems) while retaining the
virtues of linear probing such as cache obliviousness and age-less tables
under delete-heavy workloads (still untested after a month of this change).

The only real solution for truly adversarial keys is a hash keyed off of
data unobservable to attackers.  That all fits better with a few families
of user-pluggable/define-switchable hashes which can be provided in a
separate PR more about `hashes.nim`.

This PR carefully preserves the better (but still hard coded!) probing
of the  `intsets` and other recent fixes like `move` annotations, hash
order invariant tests, `intsets.missingOrExcl` fixing, and the move of
`rightSize` into `hashcommon.nim`.

* Fix `data.len` -> `dataLen` problem.

* This is an alternate resolution to https://github.com/nim-lang/Nim/issues/13393
(which arguably could be resolved outside the stdlib).

Add version1 of Wang Yi's hash specialized to 8 byte integers.  This gives
simple help to users having trouble with overly colliding hash(key)s.  I.e.,
  A) `import hashes; proc hash(x: myInt): Hash = hashWangYi1(int(x))`
      in the instantiation context of a `HashSet` or `Table`
or
  B) more globally, compile with `nim c -d:hashWangYi1`.

No hash can be all things to all use cases, but this one is A) vetted to
scramble well by the SMHasher test suite (a necessarily limited but far
more thorough test than prior proposals here), B) only a few ALU ops on
many common CPUs, and C) possesses an easy via "grade school multi-digit
multiplication" fall back for weaker deployment contexts.

Some people might want to stampede ahead unbridled, but my view is that a
good plan is to
  A) include this in the stdlib for a release or three to let people try it
     on various key sets nim-core could realistically never access/test
     (maybe mentioning it in the changelog so people actually try it out),
  B) have them report problems (if any),
  C) if all seems good, make the stdlib more novice friendly by adding
     `hashIdentity(x)=x` and changing the default `hash() = hashWangYi1`
     with some `when defined` rearranging so users can `-d:hashIdentity`
     if they want the old behavior back.
This plan is compatible with any number of competing integer hashes if
people want to add them.  I would strongly recommend they all *at least*
pass the SMHasher suite since the idea here is to become more friendly to
novices who do not generally understand hashing failure modes.

* Re-organize to work around `when nimvm` limitations; Add some tests; Add
a changelog.md entry.

* Add less than 64-bit CPU when fork.

* Fix decl instead of call typo.

* First attempt at fixing range error on 32-bit platforms; Still do the
arithmetic in doubled up 64-bit, but truncate the hash to the lower
32-bits, but then still return `uint64` to be the same.  So, type
correct but truncated hash value.  Update `thashes.nim` as well.

* A second try at making 32-bit mode CI work.

* Use a more systematic identifier convention than Wang Yi's code.

* Fix test that was wrong for as long as `toHashSet` used `rightSize` (a
very long time, I think).  `$a`/`$b` depend on iteration order which
varies with table range reduced hash order which varies with range for
some `hash()`.  With 3 elements, 3!=6 is small and we've just gotten
lucky with past experimental `hash()` changes.  An alternate fix here
would be to not stringify but use the HashSet operators, but it is not
clear that doesn't alter the "spirit" of the test.

* Fix another stringified test depending upon hash order.

* Oops - revert the string-keyed test.

* Fix another stringify test depending on hash order.

* Add a better than always zero `defined(js)` branch.

* It turns out to be easy to just work all in `BigInt` inside JS and thus
guarantee the same low order bits of output hashes (for `isSafeInteger`
input numbers).  Since `hashWangYi1` output bits are equally random in
all their bits, this means that tables will be safely scrambled for table
sizes up to 2**32 or 4 gigaentries which is probably fine, as long as the
integer keys are all < 2**53 (also likely fine).  (I'm unsure why the
infidelity with C/C++ back ends cut off is 32, not 53 bits.)

Since HashSet & Table only use the low order bits, a quick corollary of
this is that `$` on most int-keyed sets/tables will be the same in all
the various back ends which seems a nice-to-have trait.

* These string hash tests fail for me locally.  Maybe this is what causes
the CI hang for testament pcat collections?

* Oops. That failure was from me manually patching string hash in hashes.  Revert.

* Import more test improvements from https://github.com/nim-lang/Nim/pull/13410

* Fix bug where I swapped order when reverting the test.  Ack.

* Oh, just accept either order like more and more hash tests.

* Iterate in the same order.

* `return` inside `emit` made us skip `popFrame` causing weird troubles.

* Oops - do Windows branch also.

* `nimV1hash` -> multiply-mnemonic, type-scoped `nimIntHash1` (mnemonic
resolutions are "1 == identity", 1 for Nim Version 1, 1 for
first/simplest/fastest in a series of possibilities.  Should be very
easy to remember.)

* Re-organize `when nimvm` logic to be a strict `when`-`else`.

* Merge other changes.

* Lift constants to a common area.

* Fall back to identity hash when `BigInt` is unavailable.

* Increase timeout slightly (probably just real-time perturbation of CI
system performance).
2020-04-15 20:11:18 +02:00
Timothee Cour
ab5e26c53c fix some codegen bugs: NIM_BOOL, NIM_STATIC_ASSERT, --passc:-std=... (etc) (#13798)
* fix cgen bool D20200328T203812
* --passc:std=c++17 (etc) now works instead of silently ignored
* document caveats for NIM_NIL
2020-04-07 15:17:30 +02:00
Timothee Cour
f1fd3ef7f4 fix https://github.com/timotheecour/Nim/issues/88 (#13865) [backport:1.2] 2020-04-06 00:24:35 +02:00
Timothee Cour
af9c852701 fix nim doc subdir/foo which was generating broken css; + other fixes (#13647)
* docgen: minor refactoring via docOutDir
* fix css for `nim doc subdir/foo` without --outdir nor -o
* tcompilesetting.nim: keep `git status` clean
* re-enable pkg nimgame2 that got fixed upstream
2020-03-17 13:44:37 +01:00
Andreas Rumpf
614fb7567c std/compilesettings implementation (#13584)
* Implement compileSetting() and compileSettingSeq()
* Change from magic to vmop
* better design for querySetting

Co-authored-by: genotrance <dev@genotrance.com>
2020-03-04 13:46:42 +01:00
Timothee Cour
e70294dff2 enable testing -d:nimHasLibFFI mode (#13091) 2020-02-04 14:08:56 +01:00
Timothee Cour
b462baed65 VM: allow overriding MaxLoopIterations without rebuilding nim (#13233) 2020-01-23 10:53:30 +01:00
Timothee Cour
ee1563ef33 VM FFI: write(stderr, msg) and fprintf(cstderr, msg) now work at CT (#13083) 2020-01-12 13:44:43 +01:00
cooldome
a3df1b55f3 fixes #13013, reverts previous changes to readLines() (#13036) [backport]
* Revert "remove default argument for readLines (#12807) [backport]"

This reverts commit c949b81efd.
2020-01-05 09:22:41 +01:00