Commit Graph

20246 Commits

Author SHA1 Message Date
metagn
1b61e71bb8 Remove string == nil/nil == string error (#20222)
* Remove string == nil/nil == string error

This was to help migration for `nil` strings being removed, but `nil` strings have been gone for a while now.

* remove isNil too
2022-08-20 20:07:33 -04:00
havardjohn
f4bbf3bf0b Add use of Windows Wide CRT API for env. vars (#20084)
* Add use of Windows Wide CRT API for env. vars

Replaces use of CRT API `getenv` and `putenv` with respectively
`_wgetenv` and `_wputenv`. Motivation is to reliably convert environment
variables to UTF-8, and the wide API is best there, because it's
reliably UTF-16.

Changed the hack in `lib/std/private/win_setenv.nim` by switching the
order of the Unicode and MBCS environment update; Unicode first, MBCS
second. Because `_wgetenv`/`_wputenv` is now used, the Unicode
environment will be initialized, so it should always be updated.

Stop updating MBCS environment with the name of `getEnv`. It's not
necessarily true that MBCS encoding and the `string` encoding is the
same. Instead convert UTF-16 to current Windows code page with
`wcstombs`, and use that string to update MBCS.

Fixes regression in `6b3c77e` that caused `std/envvars.getEnv` or
`std/os.getEnv` on Windows to return non-UTF-8 encoded strings.

Add tests that test environment variables with Unicode characters in
their name or value.

* Fix test issues

Fixes

* `nim cpp` didn't compile the tests
* Nimscript import of `tosenv.nim` from `test_nimscript.nims` failed
  with "cannot importc"

* Fix missing error check on `wcstombs`

* Fix ANSI testing errors

* Separate ANSI-related testing to their own tests, and only executing
  them if running process has a specific code page
  * Setting locale with `setlocale` was not reliable and didn't work on
    certain machines
* Add handling of a "no character representation" error in second
  `wcstombs` call

* tests/newruntime_misc: Increment allocCount

Increments overall allocations in `tnewruntime_misc` test. This is
because `getEnv` now does an additional allocation: allocation of the
UTF-16 string used as parameter to `c_wgetenv`.

* Revert "tests/newruntime_misc: Increment allocCount"

This reverts commit 4d4fe8bd3e.

* tests/newruntime_misc: Increment allocCount on Windows

Increments overall allocations in `tnewruntime_misc` test for Windows.
This is because `getEnv` on Windows now does an additional allocation:
allocation of the UTF-16 string used as parameter to `c_wgetenv`.

* Refactor, adding suggestions from code review

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>

* Document, adding suggestions

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>

Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
2022-08-20 04:30:11 -04:00
ringabout
641381e3d4 fixes #20149; fixes #16762; hintAsError and warningAsError now ignore foreign packages (#20151)
* fixes #20149;  hintAsError/warningAsError ignores foreign packages

* add changelog

* fixes the test

* remove

* fixes tests again

* fix

* I'm careless

Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
2022-08-19 16:24:09 -04:00
ringabout
c9c1c97f1e make sure tools/heapdumprepl.nim continues to compile (#20146) 2022-08-19 15:42:51 -04:00
ee7
e8657c7107 make implicit cstring conversions explicit (#19488)
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
2022-08-19 15:40:53 -04:00
jgirvin-venturi
7fe6dedb62 Adds missing SEEK_ POSIX constants for FreeRTOS (#20241) 2022-08-19 15:40:17 -04:00
Andreas Rumpf
b1fe1690c4 fixes #20107 (#20246) [backport] 2022-08-19 13:42:08 +02:00
Andrey Makarov
1c31de361d Markdown code blocks part 5 (#20236)
No logic was added, just a few more `*.md` files have been migrated.
2022-08-17 15:20:22 -04:00
Judd
60f6724b70 fix comment in the Nim manual (#20234)
fix comment

there is no `y` in the example.
2022-08-17 09:48:52 +08:00
Andrey Makarov
9f408ea943 Don't require blank line before Markdown code (#20215)
Fixes bug reported in https://github.com/nim-lang/Nim/pull/20189
affecting nimforum.
2022-08-15 18:37:45 -04:00
Dan Rose
c579243e0c Pass check condition directly to if (#20217)
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'`
2022-08-15 18:37:10 -04:00
metagn
691026f507 changelog fixes again (#20206)
changelog fixes again [skip ci]
2022-08-15 18:33:43 -04:00
ringabout
a4d63ca8ba closes #12955; add testcase (#20223) 2022-08-15 18:50:12 +08:00
ringabout
c0b25f33c7 add version-1-6 and version-1-2 to triggered branches (#20214)
* add version-1-6 and version-1-2 to triggered branches

* Update .github/workflows/ci_packages.yml

* use quote
2022-08-14 18:42:52 +08:00
ringabout
d2318d9ccf closes #15316; add testcase (#20213) 2022-08-13 22:23:11 +08:00
Andrey Makarov
713f39083e Markdown code blocks part 4 (#20189)
No logic was added, just 8 more files have been migrated.
2022-08-12 14:33:43 -04:00
ringabout
8155837cde CI upgrade to ubuntu-20.04 (#20182)
* CI upgrade to ubuntu-20.04 

The ubuntu-18.04 environment is deprecated, consider switching to ubuntu-20.04(ubuntu-latest), or ubuntu-22.04 instead. For more details see https://github.com/actions/virtual-environments/issues/6002

* Update azure-pipelines.yml
2022-08-12 21:57:00 +08:00
ringabout
1a7b33942b closes #6559; add testcase (#20200) 2022-08-12 09:03:10 +08:00
ringabout
ff25103c9a Show beatutiful html instead of ugly markdown preview (#20196) 2022-08-11 21:30:06 +08:00
ringabout
e559cd0c3a improve deprecation error messages (#20197) 2022-08-11 14:04:12 +08:00
metagn
31b7a25e1e fix broken runnableExamples for getWeeksInIsoYear (#20193)
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.
2022-08-11 09:39:18 +08:00
ringabout
5a502d7884 help our poor CI; don't run CI on other branches for push (#20184) 2022-08-09 15:47:19 -04:00
Ivan Yonchovski
ec2bc2a50e Build compiler with --noNimblePath (#20168)
- Fixes https://github.com/nim-lang/Nim/issues/18840
2022-08-09 14:04:52 -04:00
ee7
b4157f6772 docs: fix some spelling errors (#19816)
* docs: fix some spelling errors

* contributing: fix spelling error

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>

* Update contributing.md

* Update intern.md

* Update manual.md

* Update manual_experimental_strictnotnil.md

* Update nimgrep_cmdline.txt

* Update pegdocs.txt

* Update testament.md

* Update tut1.md

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
2022-08-09 14:01:46 -04:00
ringabout
e8ae2dc90b bootstrap the compiler with nimPreviewSlimSystem (#20176)
* bootstrap the compiler with nimPreviewSlimSystem

* threads
2022-08-09 16:32:29 +08:00
ringabout
cddd4de658 fixes broken ssl tests (#20181) 2022-08-09 11:48:17 +08:00
ringabout
80a0dc295b update the docs of arc following up #19749 (#19752)
Co-authored-by: flywind <43030857+xflywind@users.noreply.github.com>
2022-08-08 16:56:37 +08:00
ringabout
4f4501abbc fixes links in the readme (#20167) 2022-08-07 23:50:55 +08:00
ringabout
fd6640fcda [minor] don't find "Hint: gc" for action (#20170) 2022-08-07 23:50:26 +08:00
ringabout
3bd935f331 fixes #20153; do not escape _ for mysql [backport] (#20164)
* 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>
2022-08-05 17:15:58 -04:00
konsumlamm
3fef2fd52c Improve error message for strutils.addf (#20157)
Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
2022-08-05 13:44:21 -04:00
ringabout
714eb65866 remove annoying dropdowns from the bug form (#20154)
* Update bug_report.yml

* Update bug_report.yml

* Update bug_report.yml
2022-08-05 02:56:08 +08:00
Sojin
0641df33aa Two broken links found (#20121)
Updated the two broken internal links: rebuilding the compiler, reproducible builds
2022-08-04 12:53:42 -04:00
Juan Carlos
2f3980f491 Add bug form (#19913)
* Add Bug Form

* Add Bug Form

* Add Bug Form

* Add Bug Form

* https://github.com/nim-lang/Nim/pull/19913#issuecomment-1160663243

* https://github.com/nim-lang/Nim/pull/19913#issuecomment-1160663243

* Update .github/ISSUE_TEMPLATE/bug_report.yml

Co-authored-by: Yardanico <tiberiumk12@gmail.com>

* Update .github/ISSUE_TEMPLATE/bug_report.yml

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>

* Update .github/ISSUE_TEMPLATE/bug_report.yml

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>

* Update .github/ISSUE_TEMPLATE/bug_report.yml

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>

* Update .github/ISSUE_TEMPLATE/feature_request.yml

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>

* Update .github/ISSUE_TEMPLATE/feature_request.yml

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>

* Do not Star Nim on Github

* No backwards compat problems

* Typo

Co-authored-by: Yardanico <tiberiumk12@gmail.com>
Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
2022-08-04 11:15:22 +02:00
Andrey Makarov
a34dd3d77a Markdown code blocks part 3 (#20117)
No logic was added, just 4 more files migrated.
2022-08-04 09:32:23 +02:00
ringabout
2aeb0d516b fixes #20132; fixes the broken jsondoc comand [backport] (#20135)
* fixes #20132; fixes the broken jsondoc comand

* add testcase
2022-08-04 08:49:51 +02:00
gecko
7af484da94 Add client.close() in httpclient examples. (#20118)
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!
2022-08-04 06:46:08 +02:00
ringabout
09840c09e4 closes #20123; remove builds.sr.ht (#20131) 2022-08-03 16:05:57 -04:00
ringabout
c08c455016 Revert "enable nimPreviewDotLikeOps" (#19919)
* Revert "enable nimPreviewDotLikeOps (#19598)"

This reverts commit 6773ffa63d.

* add deprecated message

Co-authored-by: flywind <43030857+xflywind@users.noreply.github.com>
2022-08-03 22:39:14 +08:00
Yuriy Glukhov
0d734d7966 Fixed compilation of void closureiters with try stmt (#20138) [backport] 2022-08-03 08:46:36 +02:00
random-bites
02cbd7dc53 Edits to sections 'Open arrays' and 'varargs'. (#20140) 2022-08-03 08:44:14 +02:00
Sultan Al Isaiee
da267911ec [Changelog] Add Wider Ascii Chars sets string formatting in strutils.nim (#20137)
* Add Wider Ascii Chars sets string formatting in strutils.nim

Add Wider Ascii Chars sets for string formatting (#19994) (#20120):
- Added `UppercaseLetters`, `LowercaseLetters` The set of UppercaseLetters and lowercase ASCII letters.
- Added `PunctuationChars` The set of all ASCII punctuation characters.
- Added `PrintableChars` The set of all printable ASCII characters (letters, digits, whitespace, and punctuation characters).

* Update changelog.md

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>

* Update changelog.md

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
2022-08-02 19:50:42 +08:00
ringabout
59befed8ee prevent cache thrashing (#20129)
* 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>
2022-08-02 00:06:27 +08:00
Clay Sweetser
77891cedae Fix "Add Wider Ascii Chars sets and func for string formatting" (#20120) 2022-07-31 23:24:14 -04:00
Sultan Al Isaiee
3987a3bf97 Add Wider Ascii Chars sets and func for string formatting (#19994)
* 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>
2022-07-31 20:20:25 -04:00
quantimnot
313ce91533 [Doc] Fix some minor markup errors in manual (#20112)
* Fix header level for noalias pragma section.
* Fix code snippet outside of code block that raised an error with `rst2html`.
* Fix broken 'Convertible relation' links that were raising warnings.

Co-authored-by: quantimnot <quantimnot@users.noreply.github.com>
2022-07-31 20:08:01 -04:00
ringabout
a8590d6707 [ORC] replace threadpool with createThread in the runnableExamples (#20106)
replace threadpool with createThreads in the runnableExamples
2022-07-31 20:02:23 -04:00
ringabout
86fc78a9c0 replace the broken link for ORC implementation with a working one (#20105) 2022-07-31 20:01:36 -04:00
Andrey Makarov
40e0048a50 Highlight Nim default in Markdown code in .nim (#20110)
Highlight Nim by default in Markdown code in .nim
2022-07-31 15:38:00 +02:00
Sojin
99dd588d6b The internal link to koch.rst docs was broken (#20113)
Broken Link found for koch.rst docs

The Current internal link was broken. Updated with a new link to the same path
2022-07-31 11:07:06 +02:00