summary refs log tree commit diff stats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* make implicit cstring conversions explicit (#19488)ee72022-08-1911-50/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Nim manual says that an implicit conversion to cstring will eventually not be allowed [1]: A Nim `string` is implicitly convertible to `cstring` for convenience. [...] Even though the conversion is implicit, it is not *safe*: The garbage collector does not consider a `cstring` to be a root and may collect the underlying memory. For this reason, the implicit conversion will be removed in future releases of the Nim compiler. Certain idioms like conversion of a `const` string to `cstring` are safe and will remain to be allowed. And from Nim 1.6.0, such a conversion triggers a warning [2]: A dangerous implicit conversion to `cstring` now triggers a `[CStringConv]` warning. This warning will become an error in future versions! Use an explicit conversion like `cstring(x)` in order to silence the warning. However, some files in this repo produced such a warning. For example, before this commit, compiling `parsejson.nim` would produce: /foo/Nim/lib/pure/parsejson.nim(221, 37) Warning: implicit conversion to 'cstring' from a non-const location: my.buf; this will become a compile time error in the future [CStringConv] /foo/Nim/lib/pure/parsejson.nim(231, 39) Warning: implicit conversion to 'cstring' from a non-const location: my.buf; this will become a compile time error in the future [CStringConv] This commit resolves the most visible `CStringConv` warnings, making the cstring conversions explicit. [1] https://github.com/nim-lang/Nim/blob/d2318d9ccfe6/doc/manual.md#cstring-type [2] https://github.com/nim-lang/Nim/blob/d2318d9ccfe6/changelogs/changelog_1_6_0.md#type-system
* Adds missing SEEK_ POSIX constants for FreeRTOS (#20241)jgirvin-venturi2022-08-191-0/+4
|
* Don't require blank line before Markdown code (#20215)Andrey Makarov2022-08-151-5/+11
| | | | Fixes bug reported in https://github.com/nim-lang/Nim/pull/20189 affecting nimforum.
* Pass check condition directly to if (#20217)Dan Rose2022-08-151-2/+6
| | | | | | | | | | | | | | | | | | When checking conditions, pass `check` untyped argument directly to if. This results in better error messages when the condition is malformed. Previously `check 1` would fail at compile time with `Error: type mismatch: got 'int literal(-2)' for '-2' but expected 'bool'` Now it fails with `Error: type mismatch: got 'int literal(1)' for '1' but expected 'bool'`. Similarly `check "foo"` would fail with ``` Error: type mismatch: got <string> but expected one of: proc `not`(a: typedesc): typedesc first type mismatch at position: 1 required type for a: typedesc but expression '"somestring"' is of type: string ... ``` Now it fails with `Error: type mismatch: got 'string' for '"somestring"' but expected 'bool'`
* improve deprecation error messages (#20197)ringabout2022-08-111-4/+2
|
* fix broken runnableExamples for getWeeksInIsoYear (#20193)metagn2022-08-111-2/+2
| | | | | Based on what I understand from [Wikipedia](https://en.wikipedia.org/wiki/ISO_week_date#Weeks_per_year), 2001 does not have 53 weeks, but 2004, 2009, 2015, 2020 do. The years 2000 and 2001 seem to be copy pasted from the `getDaysInYear` example above. The result of `getWeeksInIsoYear` also seem to match up with Wikipedia. That means these runnableExamples were never tested. Why is this the case? I only discovered this in #20091.
* bootstrap the compiler with nimPreviewSlimSystem (#20176)ringabout2022-08-0911-0/+42
| | | | | * bootstrap the compiler with nimPreviewSlimSystem * threads
* update the docs of arc following up #19749 (#19752)ringabout2022-08-081-2/+2
| | | Co-authored-by: flywind <43030857+xflywind@users.noreply.github.com>
* fixes #20153; do not escape `_` for mysql [backport] (#20164)ringabout2022-08-051-2/+1
| | | | | | | | | | | * fixes #20153; do not escape `_` for mysql * add a test * Update db_mysql.nim * Update tdb_mysql.nim Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
* Improve error message for `strutils.addf` (#20157)konsumlamm2022-08-051-8/+8
| | | Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* Add client.close() in httpclient examples. (#20118)gecko2022-08-041-9/+25
| | | | | Without this, the httpclient examples are essentially setting you up for failure. I was bitten by this when my app became unable to open any more sockets. I'm not entirely sure how long this will relevant, as I hope destructors will be added to an upcoming version of the stdlib. But figured it was worth submitting anyways!
* prevent cache thrashing (#20129)ringabout2022-08-021-1/+3
| | | | | | | | | | | | * prevent cache thrash Co-authored-by: Charles Blake <cb@cblake.net> * Update lib/pure/random.nim Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> Co-authored-by: Charles Blake <cb@cblake.net> Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
* Fix "Add Wider Ascii Chars sets and func for string formatting" (#20120)Clay Sweetser2022-07-311-3/+3
|
* Add Wider Ascii Chars sets and func for string formatting (#19994)Sultan Al Isaiee2022-07-311-12/+25
| | | | | | | | | | | | | | | | | | | | | * Add more Ascii Chars sets - add UpperCaseLetters set - add LowerCaseLetters set - add Punctuations set - add PrintablesNoWhiteSpace set - add Printables set - add isPunctuationAscii func - add isPrintableAscii func * Omit isPunctuationAscii and isPrintableAscii procs * Apply suggestions for adding Wider Ascii Chars sets Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com> * Update strutils.nim Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
* [ORC] replace threadpool with createThread in the runnableExamples (#20106)ringabout2022-07-311-9/+16
| | | replace threadpool with createThreads in the runnableExamples
* replace the broken link for ORC implementation with a working one (#20105)ringabout2022-07-311-1/+1
|
* Highlight Nim default in Markdown code in .nim (#20110)Andrey Makarov2022-07-312-11/+16
| | | Highlight Nim by default in Markdown code in .nim
* remove shallowCopy for ARC/ORC (#20070)ringabout2022-07-263-20/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | * remove shallowCopy for ARC/ORC * use move * fix * more fixes * typo * Update lib/system.nim * follow * add nodestroy * move * copy string * add a changelog entry Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com> Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fixes #20089; remove setPointer since strings/seqs are not pointers with ORC ↵ringabout2022-07-261-2/+8
| | | | | (#20090) fixes #20089; remove setPointer since strings/seqs are not pointers anymore
* .forbids pragma: defining forbidden tags (#20050)Lancer112112022-07-261-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * .forbids pragma: defining illegal effects for proc types This patch intends to define the opposite of the .tags pragma: a way to define effects which are not allowed in a proc. * updated documentation and changelogs for the forbids pragma * renamed notTagEffects to forbiddenEffects * corrected issues of forbids pragma the forbids pragma didn't handle simple restrictions properly and it also had issues with subtyping * removed incorrect character from changelog * added test to cover the interaction of methods and the forbids pragma * covering the interaction of the tags and forbids pragmas * updated manual about the forbids pragma * removed useless statement * corrected the subtyping of proc types using the forbids pragma * updated manual for the forbids pragma * updated documentations for forbids pragma * updated nim docs * updated docs with rsttester.nim * regenerated documentation * updated rst docs * Update changelog.md Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> * updated changelog * corrected typo Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* Markdown code blocks part 2; migrate Nim Manual (#20080)Andrey Makarov2022-07-251-24/+30
| | | | | * Change headings underscored by `~~~` to `###` * Markdown code blocks part 2; migrate Nim Manual
* fix #20067, fix #18976 [backport] (#20069)metagn2022-07-221-1/+3
|
* replace shallowcopy with move in ARC/ORC (#20061)flywind2022-07-181-6/+6
|
* Improve rand(bool) (#20045)Antonis Geralis2022-07-181-2/+4
| | | | | | | | | | | | | | | | | | | * Improve rand(bool) * Use sign test instead of mod 2 * Use mod 2 again, as it works for js * Use right shift as suggested by the authors of xoroshiro * Update random.nim * General case doesn't need any right shift it was correct to begin with * Update random.nim * add comment Co-authored-by: flywind <43030857+xflywind@users.noreply.github.com>
* epoll: correct mapping [backport] (#20058)Jacek Sieka2022-07-181-5/+14
| | | | | | | * epoll: correct mapping `epoll_data` is a union and `epoll_event` is packed on `amd64` * names
* Fixed typo in std/os doc (#20054)LetThereBeLemons2022-07-181-1/+1
| | | Fixed typo
* fix `pthread_mutex_t` size (#20055)Jacek Sieka2022-07-181-1/+1
|
* Display protocol name in exceptions raised by getProtoByName() (#19808)kraptor2022-07-161-1/+1
|
* Make `random.rand` work with `Ordinal` (#20043)Amjad Ben Hedhili2022-07-161-6/+9
| | | | | | | * Make `random.rand` work with `Ordinal` * Add changelog entry * It's fine to cast to char
* make AsyncSocket.getPeerAddr work ; fix #15022 (#20038)David Krause2022-07-161-0/+2
| | | Signed-off-by: David Krause <enthus1ast@users.noreply.github.com>
* Improve Markdown code blocks & start moving docs to Markdown style (#19954)Andrey Makarov2022-07-152-36/+119
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - add additional parameters parsing (other implementations will just ignore them). E.g. if in RST we have: .. code:: nim :test: "nim c $1" ... then in Markdown that will be: ```nim test="nim c $1" ... ``` - implement Markdown interpretation of additional indentation which is less than 4 spaces (>=4 spaces is a code block but it's not implemented yet). RST interpretes it as quoted block, for Markdown it's just normal paragraphs. - add separate `md2html` and `md2tex` commands. This is to separate Markdown behavior in cases when it diverges w.r.t. RST significantly — most conspicously like in the case of additional indentation above, and also currently the contradicting inline rule of Markdown is also turned on only in `md2html` and `md2tex`. **Rationale:** mixing Markdown and RST arbitrarily is a way to nowhere, we need to provide a way to fix the particular behavior. Note that still all commands have **both** Markdown and RST features **enabled**. In this PR `*.nim` files can be processed only in Markdown mode, while `md2html` is for `*.md` files and `rst2html` for `*.rst` files. - rename `*.rst` files to `.*md` as our current default behavior is already Markdown-ish - convert code blocks in `docgen.rst` to Markdown style as an example. Other code blocks will be converted in the follow-up PRs - fix indentation inside Markdown code blocks — additional indentation is preserved there - allow more than 3 backticks open/close blocks (tildas \~ are still not allowed to avoid conflict with RST adornment headings) see also https://github.com/nim-lang/RFCs/issues/355 - better error messages - (other) fix a bug that admonitions cannot be used in sandbox mode; fix annoying warning on line 2711
* [Orc] fixes "streams.readDataStr segafaults" when accepting a string ↵flywind2022-07-151-0/+5
| | | | | literal (#20019) [backport] fixes streams.readDataStr accept a string literal
* fixes #20015; document `shallowCopy` does a deep copy with ARC/ORC (#20025)flywind2022-07-141-0/+2
|
* Add sink and lent annotations to the critbits module (#20021)silent-observer2022-07-141-8/+8
| | | | | | | | | * Add sink and lent to critbits * Remove lent for pairs I guess lent doesn't work well inside tuples * Remove lent from template in critbits Apparently this also doesn't work, because some checks failed
* Fixes Compilation error with --app:lib (#19965)Juan M Gómez2022-07-101-1/+1
| | | | Fixes Compilation error with --app:lib when a module tries to pull os.paramStr on posix by throwing a runtime exception instead. More details here: #19964
* sysrand: fix syscall signature [backport] (#19982)Jacek Sieka2022-07-071-4/+3
| | | | | sysrand: fix syscall signature `syscall` is a `C` varags function
* Fixes return values of execCmd on macos (#19963)Daniel Clarke2022-07-051-1/+1
| | | | | | | * Fixes return values of execCmd on macos * update tests to use existing structure Co-authored-by: daniel <danielclarke@wearepopgun.com>
* Fixing `nimRawSetJmp` for vcc and clangcl on Windows (#19959)rockcavera2022-07-041-17/+21
| | | | | | | | | | | | | * fix vcc rawsetjmp * changing `_longjmp()` to `longjmp()` and `_setjmp()` to `setjmp()` * fix * fix setjmp to clangcl on Windows * fix genTrySetjmp() to clangcl on Windows
* jsffi add missing braces (#19948)Juan Carlos2022-06-301-10/+10
| | | js codegen add missing whitespaces and braces
* Fix jsre (#19917)Juan Carlos2022-06-281-3/+5
| | | | | * Fixes for jsre to make it more safe at runtime on some edge cases * https://github.com/nim-lang/Nim/pull/19917#issuecomment-1162692893
* fix typo in nre.nim (#19915)flintforge2022-06-211-2/+1
| | | | | Update nre.nim typo in proc replace description
* Fix nimRawSetjmp for VCC [backport: 1.2] (#19899)Tanguy2022-06-201-1/+1
|
* Better range error messages (#19867)Tanguy2022-06-151-0/+3
| | | | | | | * Better range error messages * Revert to old behavior for arrays * Small corrections
* Windows: enable nimRawSetjmp by default [backport] (#19891)Tanguy2022-06-141-0/+7
| | | | | | | | | * Windows: enable nimRawSetjmp by default See #19197. The default setjmp can randomly segfault on windows * Attempt to disable the flag for bootstraping * Disable styleCheck for c_setjmp
* Correctly import libcrypto functions using dynlib (#19881)Ardek Romak2022-06-131-35/+37
|
* Pass headers and body correctly to FetchOptions (#19884) [backport]Jake Leahy2022-06-131-2/+3
| | | | | | | | | * Pass headers to FetchOptions Don't pass body if method is HttpGet or HttpHead * Syntax fixes * Restart CI
* Friendlier error message with solution (#19880)Carlo Capocasa2022-06-111-0/+5
| | | | | | | | | | | | | * Add helpful suggestion, should always apply * mention var param limitation in async docs * Update compiler/lambdalifting.nim whoops thanks Co-authored-by: flywind <43030857+xflywind@users.noreply.github.com> Co-authored-by: flywind <43030857+xflywind@users.noreply.github.com>
* [js] add testcase for array indexDefect and remove todo (#19838)flywind2022-06-101-4/+0
| | | | | | | | | * remove unused opcSubstr * [js] add testcase for array indexDefect * Revert "remove unused opcSubstr" This reverts commit cb461f2545234d62c1e0b83318f3e5495c97de52.
* remove noop option `gc:v2` (#19810)flywind2022-06-101-12/+2
| | | | | * remove noop option gc:v2 * changelog
* fix #19862; make widestrs consistent between refc and orc (#19874) [backport]flywind2022-06-091-0/+3
| | | fix #19862; make widestrs consistent in refc and orc