summary refs log tree commit diff stats
path: root/lib/pure
Commit message (Collapse)AuthorAgeFilesLines
* change 'iff' to 'if' to stop "corrections" once and for all (#14182)Miran2020-05-016-20/+20
|
* discardable async procs are now an error (#14176)hlaaftana2020-05-011-8/+14
| | | | * add discard warning in manual
* fix sendTo and recvFrom in asyncnet (#14154)rockcavera2020-04-301-76/+40
| | | | | | | | | | | | | * added high level sendTo and recvFrom to std/asyncnet; tests were also added. * add .since annotation, a changelog entry and fixed to standard library style guide. * Improved asserts msgs and added notes for use with UDP sockets * pointers removed in parameters and fixes * added .since annotation * minor fixes
* fixes the regression #12860 caused; hotfixAraq2020-04-301-1/+1
|
* JS unittest stacktrace fix, cleanup js repr and inclrtl includes (#14168)hlaaftana2020-04-303-12/+9
|
* fixes #14054 [backport:1.2] (#14061)Andreas Rumpf2020-04-302-7/+4
| | | | | | | | | * fixes #14054 * make tests green again * more tests are green * maybe now
* fixes #14079 [backport:1.2] (#14163)Andreas Rumpf2020-04-291-1/+1
|
* Error -> Defect for defects (#13908)Jacek Sieka2020-04-2814-60/+60
| | | | | | | | | | | | | | * Error -> Defect for defects The distinction between Error and Defect is subjective, context-dependent and somewhat arbitrary, so when looking at an exception, it's hard to guess what it is - this happens often when looking at a `raises` list _without_ opening the corresponding definition and digging through layers of inheritance. With the help of a little consistency in naming, it's at least possible to start disentangling the two error types and the standard lib can set a good example here.
* StringStream & more stdlib modules support for JS/NimScript (#14095)hlaaftana2020-04-289-290/+428
| | | | | * StringStream & more stdlib modules support for JS/NimScript * change back pegs test in line with #14134
* bug fix (#14149) [backport:1.2]cooldome2020-04-281-1/+4
| | | Co-authored-by: cooldome <ariabushenko@bk.ru>
* Undefine `paramCount` & `paramStr` in nimscript.nim for *.nims (#12860)Neelesh Chandola2020-04-271-1/+17
| | | | | | | * Remove `paramStr` and `paramCount` from implicitly imported nimscript.nim * Update changelog.md * Update stable nimble commit hash Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Remove some deprecated procs from std/times (#14129)Oscar Nihlgård2020-04-271-143/+31
|
* added high level sendTo and recvFrom to std/asyncnet (UDP functionality) ↵rockcavera2020-04-261-0/+127
| | | | | | | | | (#14109) * added high level sendTo and recvFrom to std/asyncnet; tests were also added. * add .since annotation, a changelog entry and fixed to standard library style guide. * Improved asserts msgs and added notes for use with UDP sockets
* small docs fix in typetraits (#14108)hlaaftana2020-04-251-1/+1
|
* Make await a template (#12085)Alexander Ivanov2020-04-251-132/+30
| | | | | * Make await a template * Generate await inside async/multisync
* Faster readStr() (#14099)Christopher Dunn2020-04-251-6/+22
| | | | | | | | | * Faster readStr() * https://github.com/nim-lang/Nim/issues/13857 * Add .since annotation and add to changelog * Private, un-sinced proc for csource bootstrapping
* Add critbits.commonPrefixLen (#14072)Phil Krylov2020-04-241-0/+16
| | | | | | | * Add critbits.commonPrefixLen * add inline and since annotations, as well as a changelog entry Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* changed type() to typeof() in docs and error messages (#14084)hlaaftana2020-04-241-1/+1
|
* Set O_NONBLOCK flag atomically (#13934)Hiroki Noda2020-04-221-8/+4
| | | | These flags were added in Linux 2.6.27, I'm not sure Nim's minimal support Linux version.
* fix #14064 xmltree should allow create text node with raw text(non-es… ↵Bung2020-04-221-1/+11
| | | | | | | | | | | | | (#14070) * fix #14064 xmltree should allow create text node with raw text(non-escaped) eg. html style element's text * change xnRawText to VerbatimText,newRawText to newVerbatimText ,add since anotation * change changelog_1_2_0.md latest date * move change log Co-authored-by: bung87 <crc32@qq.com>
* Make debugSend/debugRecv procs public. Fixes #12189 (#12190)Chris Heller2020-04-221-3/+37
| | | | | | | * Make debugSend/debugRecv procs public. Fixes #12189 * Make checkReply proc public. Part of #12189 * Add doc comments for debugSend,debugRecv and checkReply
* Add the ability to pass title case headers to an HTTP server (#13968)wonderix2020-04-221-12/+38
| | | | | | | | | * Add the ability to pass title case headers to an HTTP server * Remove unnecessary type spec of titleCase * Replace convert member proc by isTitleCase Co-authored-by: wonderix <wonderix@googlemail.com>
* change some Exceptions to CatchableError or Defect, fixes #10288 (#14069)hlaaftana2020-04-223-4/+4
|
* base `parseEnum` on a case statement, fixes #14030 (#14046)Vindaar2020-04-222-11/+84
| | | | | | | | | | | | | | | | | | | | * base `parseEnum` on a case statement, fixes #14030 * apply simplifactions / clean up, remove `norm` node, use strVal * export `normalize` in json.nim * cmp using nimIdentNormalize, error at CT if ambiguous enum found `nimIdentNormalize` provided by @cooldome. We track all names of the branches we have created so far and error if a duplicate is found. Dummy change to make github react... * fix docstring of `nimIdentNormalize` * make `typ` arg `typedesc`, add lineinfo, call norm. only once
* Fix OS detection in a docker container (#13172)Arnaud Moura2020-04-221-32/+46
| | | | | | | * Support detection in docker container. * Get only ID information in os-release. * Add test to distros module. * Fix Linux OS detection in Windows. * Fix OS detection for FreeBSD and OpenBSD.
* fix #13222: make relativePath more robust and flexible (#13451)Timothee Cour2020-04-211-68/+90
| | | | | | | | | * * relativePath(foo) now works * relativePath(rel, abs) and relativePath(abs, rel) now work (fixes #13222) * relativePath, absolutePath, getCurrentDir now available in more targets (eg: vm, nodejs etc) * fix bug: isAbsolutePath now works with -d:js; add tests * workaround https://github.com/nim-lang/Nim/issues/13469 * remove `relativePath(path)` overload for now * add back changelog after rebase
* Add deques.peekFirst/Last(var Deque[T]) -> var T (#13542)hlaaftana2020-04-211-0/+41
| | | | | | | * Add deques.peekFirst/Last(var Deque[T]) -> var T * Add changelog entry for deques.peekFirst/Last var T overloads * Add since annotation to peekFirst/peekLast Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Add package install command for FreeBSD and OpenBSD. (#14051)Arnaud Moura2020-04-211-1/+3
|
* Times refactorings (#13949)Oscar Nihlgård2020-04-211-753/+778
|
* #12103 - CI for OpenBSD (#12105)Euan2020-04-212-11/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Working on OpenBSD CI * Condense steps into 2 steps to make output easier to follow. * Move up one directory after csources build. * Remove FreeBSD build manifest and add OpenBSD test ignores for coroutines and hot code reloading. * If runCI fails, run the test results script. * Add email trigger for build failure * Remove .git from repository URL * Disable SFML test on OpenBSD * Disable tgetaddrinfo on OpenBSD as only UDP and TCP protocols are supported. * Remove getFilePermissions as it causes CI test failures with NimScript. * Set clang as cc in nim.cfg and use gmake to build csources. * Add getCurrentDir to nimscript. * Remove duplicate getCurrentDir and check for not weirdTarget. * Add CI badge for OpenBSD. * Disable tests which allocate lots of memory for OpenBSD. * Use `CORO_BACKEND_SETJMP` on OpenBSD rather than ucontext. * Simplify building of koch * Disable t8657 on OpenBSD. See issue #13760. * Fix #12142 - tarray_of_channels fails on OpenBSD * Disable thhtpclient_ssl and tosprocterminate on OpenBSD. These tests can be enabled at a later date after fixing them. * Install libffi. * Set path to libc for openbsd. * Disable tevalffi for now. * Remove tevalffi.nim. * Use ncpuonline sysctl rather than ncpu. * Disable tacceptcloserace and tasynchttpserver on OpenBSD. * Enable tacceptcloserace and tasynchttpserver. * Fix #13775 as suggested by @alaviss - use /bin/cat on OpenBSD rather than /bin/sh. * Enable test on OpenBSD. * Disable tflowvar on OpenBSD.
* fix mapIt issues #12625 & #12639 (#14041)Judd2020-04-211-14/+36
| | | | | | | | | | | | * fix mapIt issues #12625 & #12639: 1. fallback to call `map` when the result of `op` is a closure; 2. use `items(s)` in the for loop. * fix test errors. * add comments and InType is moved. * fix ident.
* New runnableExample for `newAsyncHttpClient()` (#14045)Tristram Oaten2020-04-211-0/+11
|
* asyncdispatch: export Callback (#14042) [backport]alaviss2020-04-211-2/+2
| | | | | | This let us see the definition of `Callback` in docs, which is required to even make use of asyncdispatch. Ref #13539.
* Fix broken async httpclient exampleTristram Oaten2020-04-211-3/+7
| | | | | | | | | | | | | | | | | As the async httpclient is almost certainly the first async example beginners will want to try, we OWE it to them to give them a real example. Example repeated here for clarity: ```nim import asyncdispatch, httpclient proc asyncProc(): Future[string] {.async.} = var client = newAsyncHttpClient() return await client.getContent("http://example.com") echo waitFor asyncProc() ``` This is my first Nim contribution, please let me know if the code is right. (it runs on my machine, but may not be the best example)
* Make file descriptors from stdlib non-inheritable by default (#13201)alaviss2020-04-205-38/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * io: make file descriptors non-inheritable by default This prevents file descriptors/handles leakage to child processes that might cause issues like running out of file descriptors, or potential security issues like leaking a file descriptor to a restricted file. While this breaks backward compatibility, I'm rather certain that not many programs (if any) actually make use of this implementation detail. A new API `setInheritable` is provided for the few that actually want to use this functionality. * io: disable inheritance at file creation time for supported platforms Some platforms provide extension to fopen-family of functions to allow for disabling descriptor inheritance atomically during File creation. This guards against possible leaks when a child process is spawned before we managed to disable the file descriptor inheritance (ie. in a multi-threaded program). * net, nativesockets: make sockets non inheritable by default With this commit, sockets will no longer leak to child processes when you don't want it to. Should solves a lot of "address in use" that might occur when your server has just restarted. All APIs that create sockets in these modules now expose a `inheritable` flag that allow users to toggle inheritance for the resulting sockets. An implementation of `setInheritance()` is also provided for SocketHandle. While atomically disabling inheritance at creation time is supported on Windows, it's only implemented by native winsock2, which is too much for now. This support can be implemented in a future patch. * posix: add F_DUPFD_CLOEXEC This command duplicates file descriptor with close-on-exec flag set. Defined in POSIX.1-2008. * ioselectors_kqueue: don't leak file descriptors File descriptors internally used by ioselectors on BSD/OSX are now shielded from leakage. * posix: add O_CLOEXEC This flag allows file descriptors to be open() with close-on-exec flag set atomically. This flag is specified in POSIX.1-2008 * tfdleak: test for selectors leakage Also simplified the test by using handle-type agnostic APIs to test for validity. * ioselectors_epoll: mark all fd created close-on-exec File descriptors from ioselectors should no longer leaks on Linux. * tfdleak: don't check for selector leakage on Windows The getFd proc for ioselectors_select returns a hardcoded -1 * io: add NoInheritFlag at compile time * io: add support for ioctl-based close-on-exec This allows for the flag to be set/unset in one syscall. While the performance gains might be negliable, we have one less failure point to deal with. * tfdleak: add a test for setInheritable * stdlib: add nimInheritHandles to restore old behaviors * memfiles: make file handle not inheritable by default for posix * io: setInheritable now operates on OS file handle On Windows, the native handle is the only thing that's inheritable, thus we can assume that users of this function will already have the handle available to them. This also allows users to pass down file descriptors from memfiles on Windows with ease, should that be desired. With this, nativesockets.setInheritable can be made much simpler. * changelog: clarify * nativesockets: document setInheritable return value * posix_utils: atomically disable fd inheritance for mkstemp
* Make bitand, bitor, bitxor varargs-friendly (#13985)awr12020-04-201-9/+26
| | | | | | | | * made bitand, bitor, bitxor varargs friendly * changed new bitops to macros * changed macro signature for consistency (this technically doesn't matter) * added tests * removed redundant assert * fix literal
* unicode: minor documention improvementAraq2020-04-201-0/+1
|
* fixes #12834 (#14017)Andreas Rumpf2020-04-191-3/+3
|
* forward type alignment information to seqs (#12430)Arne Döring2020-04-191-2/+1
|
* Add runnableExamples to critbits module (#13994)jiro2020-04-181-25/+219
| | | | | * doc: critbit: add runnableExamples * doc: critbit: change to upper
* fix https://github.com/nim-lang/RFCs/issues/211: `var a: DateTime` compiles ↵Timothee Cour2020-04-181-3/+10
| | | | | | | and is usable (#14002) [backport:1.2] * fix https://github.com/nim-lang/RFCs/issues/211: `var a: DateTime` works * assertValidDate checks for sentinel month
* Step2: fixes #13781, fixes #13805 (#13897)cooldome2020-04-161-28/+21
| | | | | | | | | * Fix sym owner in wrapper proc * threadpool changes * revert lowerings * add newFastMoveStmt * try fixing test by switching to cpp Co-authored-by: cooldome <ariabushenko@bk.ru>
* added a .since annotation to hashIdentityAndreas Rumpf2020-04-151-2/+4
|
* Add `hashWangYi1` (#13823)c-blake2020-04-153-8/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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).
* fix #12864 static params were mutating arg types during sigmatch; fix #12713 ↵Timothee Cour2020-04-141-5/+4
| | | | | | | | | | | ; refs #13529 (#13976) * fix #12864 static params were mutating arg types during sigmatch * fix test * fix StaticParam * also fixes #12713; added test case
* Add Data URI Base64, implements RFC-2397 (#13759)Juan Carlos2020-04-131-1/+35
| | | | | | | | | | | | | | | | | * Add Data URI Base64, implements RFC-2397 * Add Data URI Base64, implements RFC-2397 * Add Data URI Base64, implements RFC-2397 * https://github.com/nim-lang/Nim/pull/13759#issuecomment-611498420 * https://github.com/nim-lang/Nim/pull/13759#issuecomment-611498420 * ReSync changelog * https://github.com/nim-lang/Nim/pull/13759#issuecomment-611498420 Co-authored-by: Dominik Picheta <dominikpicheta@googlemail.com>
* Add runnableExamples to bitops module (#13951)jiro2020-04-131-15/+143
| | | | | | | | | | | | | | | | | * doc: bitops: add runnableExamples * doc: bitops: add notes to documentation comments of macros * doc: bitops: add periods to documentation comments * doc: bitops: add static * Revert "doc: bitops: add static" This reverts commit 595ee134abcd451e73ddde963c1b3e49a275f2e5. * doc: bitops: add `var` to arguments of macros * doc: bitops: remove examples of testBit
* osproc: added a better version of waitForExit for Haiku (#13938)alaviss2020-04-101-0/+61
| | | Also modified tosprocterminate to verify waitForExit implementations.
* fixes #13863 (#13929)cooldome2020-04-081-0/+5
| | | Co-authored-by: cooldome <ariabushenko@bk.ru>
* fix #13894, httpclient hang on Http204narimiran2020-04-071-1/+1
|