summary refs log tree commit diff stats
Commit message (Collapse)AuthorAgeFilesLines
* fixes #23663; Add hash() for Path (#23664)ringabout2024-05-312-6/+17
| | | fixes #23663
* remove winim from important packages; since CI doesn't check windows ↵ringabout2024-05-301-1/+1
| | | | | platform (#23661) Cannot compile on Linux reliably
* Treat CJK Ideographs as letters in `isAlpha()` (#23651)Alexander Kernozhitsky2024-05-293-1982/+1995
| | | | | | | | | | | | | | | | | Because of the bug in `tools/parse_unicodedata.nim`, CJK Ideographs were not considered letters in `isAlpha()`, even though they have category Lo. This is because they are specified as range in `UnicodeData.txt`, not as separate characters: ``` 4E00;<CJK Ideograph, First>;Lo;0;L;;;;;N;;;;; 9FEF;<CJK Ideograph, Last>;Lo;0;L;;;;;N;;;;; ``` The parser was not prepared to parse such ranges and thus omitted almost all CJK Ideographs from consideration. To fix this, we need to consider ranges from `UnicodeData.txt` in `tools/parse_unicodedata.nim`.
* revert #23436; remove workaround (#23653)ringabout2024-05-281-2/+0
| | | revert #23436
* fixes #23635; tasks.toTask Doesn't Expect a Dot Expression (#23641)ringabout2024-05-272-4/+56
| | | | | | | fixes #23635 --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fixes #22852; fixes #23435; fixes #23645; SIGSEGV when slicing string or ↵ringabout2024-05-272-5/+10
| | | | | | | | | | | | | | | | | | seq[T] with index out of range (#23279) follow up https://github.com/nim-lang/Nim/pull/23013 fixes #22852 fixes #23435 fixes #23645 reports rangeDefect correctly ```nim /workspaces/Nim/test9.nim(1) test9 /workspaces/Nim/lib/system/indices.nim(116) [] /workspaces/Nim/lib/system/fatal.nim(53) sysFatal Error: unhandled exception: value out of range: -2 notin 0 .. 9223372036854775807 [RangeDefect] ```
* Handle arbitrarily long symlink target in `expandSymlinks()` (#23650)Alexander Kernozhitsky2024-05-271-8/+10
| | | | | | | | | | | | | | | For now, `expandSymlinks()` can handle only symlinks with lengths up to 1024. We can improve this logic and retry inside a loop with increasing lengths until we succeed. The same approach is used in [Go](https://github.com/golang/go/blob/377646589d5fb0224014683e0d1f1db35e60c3ac/src/os/file_unix.go#L446), [Rust](https://github.com/rust-lang/rust/blob/785eb65377e5d7f8d8e8b82ede044212bbd2d76e/library/std/src/sys/pal/unix/fs.rs#L1700) and [Nim's `getCurrentDir()`](https://github.com/nim-lang/Nim/blob/devel/lib/std/private/ospaths2.nim#L877), so maybe it's a good idea to use the same logic in `expandSymlinks()` also.
* Prevent font flashing in the docs (#23622)Nils Lindemann2024-05-2713-39/+52
| | | | | | | | | | ... by moving the Google font includes near the top of the head. By including them as early as possible, they are known, when the browser starts rendering the body. Test it by making the change manually in `doc/html/system.html` and then press ctrl+f5 (reload without cache). This removes the font flashing. Tested in Chrome and Firefox.
* closes #13426; adds a test case (#23642)ringabout2024-05-241-0/+87
| | | closes #13426
* Updates nimble (#23601)Juan M Gómez2024-05-231-1/+3
|
* Skip tyAlias inside semTypeTraits in case a concept accidently emits one ↵Jason Beetham2024-05-232-1/+12
| | | | (#23640)
* Minor refactoring (#23637)Andreas Rumpf2024-05-231-17/+15
|
* fixes `reifiedOpenArray`; `nkHiddenStdConv` is PathKinds1 not PathKinds0 ↵ringabout2024-05-221-2/+8
| | | | (#23633)
* fixes #23627; Simple destructor code gives invalid C (#23631)ringabout2024-05-212-8/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | fixes #23627 ```nim type TestObj = object of RootObj TestTestObj = object of RootObj testo: TestObj proc `=destroy`(x: TestTestObj) = echo "Destructor for TestTestObj" proc testCaseT() = echo "\nTest Case T" let tt1 {.used.} = TestTestObj(testo: TestObj()) ``` When generating const object fields, it's likely that we need to generate type infos for the object, which may be an object with custom hooks. We need to generate potential consts in the hooks first. https://github.com/nim-lang/Nim/pull/20433 changed the semantics of initialization. It should evaluate`BracedInit` first.
* doc(format): ospaths2,strutils: followup #23560 (#23629)lit2024-05-202-9/+9
| | | followup #23560
* doc(format): system.nim: doc of hostCPU for `loongarch64` (#23621)lit2024-05-171-1/+1
| | | | | In doc, `loongarch64` used to be written as `'"loongarch64"'` since it's [supported](https://github.com/nim-lang/Nim/pull/19223)
* provides a `$` function for `Path` (#23617)ringabout2024-05-172-0/+4
| | | Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fixes #16671; openarray conversion for object construction (#23618)ringabout2024-05-162-3/+29
| | | | | fixes #16671 related to https://github.com/nim-lang/Nim/pull/18911
* Support NetBSD/aarch64 (#23616)PHO2024-05-164-3/+6
| | | | | I could trivially port Nim to NetBSD/aarch64 because it already supported NetBSD and aarch64. I only needed to generate `c_code` for this combination.
* fixes lifting subtype calling parent's hooks (#23612)ringabout2024-05-152-2/+28
| | | | | ref https://forum.nim-lang.org/t/11587 Tested with `gcc version 14.0.1 20240412` locally
* closes #15778; adds a test case (#23613)ringabout2024-05-151-7/+29
| | | closes #15778
* fixes deprecation messages and adds missing commas (#23609)ringabout2024-05-141-3/+3
|
* fixes openarray views default values in JS (#23607)ringabout2024-05-142-2/+17
|
* fixes testament matrix doesn't work with other backends which left many JS ↵ringabout2024-05-146-11/+34
| | | | | | tests untested (#23592) Targets are not changes, which means the C binary is actually tested for JS backend
* ignore modules when looking up symbol with expected type (#23597)metagn2024-05-143-1/+20
| | | | | | | | | | | | | | | | fixes #23596 When importing a module and declaring an overloadable symbol with the same name as the module in the same scope, the module symbol can take over and make the declared overload impossible to access. Previously enum overloading had a quirk that bypassed this in a context where a specific enum type was expected but this was removed in #23588. Now this is bypassed in every place where a specific type is expected since module symbols don't have a type and so wouldn't be compatible anyway. But the issue still exists in places where no type is expected like `let x = modulename`. I don't see a way of fixing this without nerfing module symbols to the point where they're not accessible by default, which might break some macro code.
* re-enable tests (#23591)ringabout2024-05-101-4/+2
|
* Allow to `exportc` params. (#23396)Juan M Gómez2024-05-101-1/+1
| | | | By allowing `exportc` in params one can decide the name of a param or to dont mangle them.
* Add directory input support to nimpretty (#23590)Mads Hougesen2024-05-101-1/+7
| | | Feel free to close if this an unwanted addition :)
* unordered enum for better interoperability with C (#23585)ringabout2024-05-104-5/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ref https://forum.nim-lang.org/t/11564 ```nim block: # unordered enum block: type unordered_enum = enum a = 1 b = 0 doAssert (ord(a), ord(b)) == (1, 0) block: type unordered_enum = enum a = 1 b = 0 c doAssert (ord(a), ord(b), ord(c)) == (1, 0, 2) block: type unordered_enum = enum a = 100 b c = 50 d doAssert (ord(a), ord(b), ord(c), ord(d)) == (100, 101, 50, 51) block: type unordered_enum = enum a = 7 b = 6 c = 5 d doAssert (ord(a), ord(b), ord(c), ord(d)) == (7, 6, 5, 8) ```
* remove bad type inference behavior for enum identifiers (#23588)metagn2024-05-102-7/+22
| | | | | | | | | | | | | | | refs https://github.com/nim-lang/Nim/issues/23586#issuecomment-2102113750 In #20091 a bad kind of type inference was mistakenly left in where if an identifier `abc` had an expected type of an enum type `Enum`, and `Enum` had a member called `abc`, the identifier would change to be that enum member. This causes bugs where a local symbol can have the same name as an enum member but have a different value. I had assumed this behavior was removed since but it wasn't, and CI seems to pass having it removed. A separate PR needs to be made for the 2.0 branch because these lines were moved around during a refactoring in #23123 which is not in 2.0.
* adds Nim-related mimetypes back (#23589)ringabout2024-05-102-0/+9
| | | ref https://github.com/nim-lang/Nim/pull/23226
* Improve strutils.rsplit doc, proc and iterator have oppose result order. ↵lit2024-05-101-6/+6
| | | | | | | | | | | | | | (#23570) [`rsplit iterator`](https://nim-lang.org/docs/strutils.html#rsplit.i,string,char,int) yields substring in reversed order, while [`proc rsplit`](https://nim-lang.org/docs/strutils.html#rsplit%2Cstring%2Cchar%2Cint)'s order is not reversed, but its doc only declare ``` The same as the rsplit iterator, but is a func that returns a sequence of substrings. ```
* fixes #23552; Invalid codegen when trying to mannualy delete distinct seq ↵ringabout2024-05-082-6/+16
| | | | | (#23558) fixes #23552
* Add a note about the sideeffect pragma (#23543)Antonis Geralis2024-05-081-0/+2
|
* Add Complex version of almostEqual function (#23549)Angel Ezquerra2024-05-082-3/+21
| | | | | | | | This adds a version of `almostEqual` (which was already available for floats) thata works with `Complex[SomeFloat]`. Proof that this is needed is that the first thing that the complex.nim runnable examples block did before this commit was define (an incomplete) `almostEqual` function that worked with complex values.
* fix semFinishOperands for bracket expressions [backport:2.0] (#23571)metagn2024-05-082-7/+32
| | | | | | | | | | | | | | | | fixes #23568, fixes #23310 In #23091 `semFinishOperands` was changed to not be called for `mArrGet` and `mArrPut`, presumably in preparation for #23188 (not sure why it was needed in #23091, maybe they got mixed together), since the compiler handles these later and needs the first argument to not be completely "typed" since brackets can serve as explicit generic instantiations in which case the first argument would have to be an unresolved generic proc (not accepted by `finishOperand`). In this PR we just make it so `mArrGet` and `mArrPut` specifically skip calling `finishOperand` on the first argument. This way the generic arguments in the explicit instantiation get typed, but not the unresolved generic proc.
* fixes 12381, HttpClient socket handle leak (#23575)Marius Andra2024-05-081-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ## Bug Fixes https://github.com/nim-lang/Nim/issues/12381 - HttpClient socket handle leak To replicate the bug, run the following code in a loop: ```nim import httpclient while true: echo "New loop" var client = newHttpClient(timeout = 1000) try: let response = client.request("http://10.44.0.4/bla", httpMethod = HttpPost, body = "boo") echo "HTTP " & $response.status except CatchableError as e: echo "Error sending logs: " & $e.msg finally: echo "Finally" client.close() ``` Note the IP address as the hostname. I'm directly connecting to a plausible local IP, but one that does not resolve, as I have everything under 10.4.x.x. The output looks like this to me: ``` New loop Error sending logs: Operation timed out Finally New loop Error sending logs: Operation timed out Finally New loop ... ``` In Nim 2.0.4, running the code above leaks the socket: <img width="944" alt="Screenshot 2024-05-05 at 22 00 13" src="https://github.com/nim-lang/Nim/assets/53387/ddac67db-d7df-45e6-b7a5-3d42f79775ea"> ## Fix With the added line of code, each old socket is cleanly removed: <img width="938" alt="Screenshot 2024-05-05 at 21 54 18" src="https://github.com/nim-lang/Nim/assets/53387/5b0b4b2d-d4f0-4e74-a9cf-74aec0c50d2e"> I believe the line below, `closeUnusedFds(ord(domain))` was supposed to clean up the failed connection attempts, but it failed to do so for the last one, assuming it succeeded. Yet it didn't. This fix makes sure failed connections are closed immediately. ## Tests I don't have a test with this PR. When testing locally, the `connect(lastFd, ..)` call on line 2032 blocks for ~75 seconds, ignoring the http timeout. I fear any test I could add would either 1) take way too long, 2) one day run in an environment where my randomly chosen IP is real, yielding in weird flakes. The only bug i can imagine is if running `lastFd.close()` twice is a bad idea. I tested by actually running it twice, and... no crash/op? So seems safe? I'm hoping the CI run will be green, and this will be enough. However I'm happy to take feedback on how I should test this, and do the necessary changes. ~Edit: looks like a test does fail, so moving to a draft while I figure this out.~ Attempt 2 fixed it.
* rework `wasMoved`, `move` on the JS backend (#23577)ringabout2024-05-089-69/+35
| | | | | `reset`, `wasMoved` and `move` doesn't support primitive types, which generate `null` for these types. It is now produce `x = default(...)` in the backend. Ideally it should be done by ast2ir in the future
* fixes #22409; don't check style for enumFieldSymChoice in the function (#23580)ringabout2024-05-083-6/+7
| | | fixes #22409
* fixes #23442, fix for FileId under Windows (#23444)lit2024-05-081-4/+4
| | | | | | | | | | | See according issue: Details: <https://github.com/nim-lang/Nim/issues/23442#issuecomment-2021763669> --------- Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Skips generic owner when mangling instances (#23563)Juan M Gómez2024-05-072-5/+6
|
* bring `telebot` back (#23578)ringabout2024-05-071-1/+1
| | | | | Reverts nim-lang/Nim#23566 ref https://github.com/ba0f3/telebot.nim/commit/afe4ad877ec015091f5b6fde32ecb2502fe59a3f
* fixes CI failure (#23566)ringabout2024-05-041-1/+1
|
* fixes #23556; typeinfo.extendSeq generates random values in ORC (#23557)ringabout2024-05-033-2/+28
| | | | | fixes #23556 It should somehow handle default fields in the future
* Update unicode.nim: cmpRunesIgnoreCase: fix doc format (#23560)lit2024-05-021-6/+6
| | | | | | Its doc used to render wrongly where `>` is considered as quote block: ![image](https://github.com/nim-lang/Nim/assets/97860435/4aeda257-3231-42a5-9dd9-0052950a160e)
* fixes #23419; internal error with void in generic array instantiation (#23550)ringabout2024-05-012-3/+11
| | | | | | | | | fixes #23419 `void` is only supported as fields of objects/tuples. It shouldn't allow void in the array. I didn't merge it with taField because that flag is also used for tyLent, which is allowed in the fields of other types.
* fixes #23321; Error: internal error: openArrayLoc: ref array[0..0, int] (#23548)ringabout2024-04-292-1/+39
| | | | | | | | fixes #23321 In the function `mapType`, ptrs (tyPtr, tyVar, tyLent, tyRef) are mapped into ctPtrToArray, the dereference of which is skipped in the `genref`. We need to skip these ptrs in the function `genOpenArraySlice`.
* fix typo: "As can been seen" to "As can be seen" (#23544)yojiyama72024-04-281-1/+1
|
* fixes #23531; fixes invalid meta type accepted in the object fields (#23532)ringabout2024-04-262-9/+78
| | | | | fixes #23531 fixes #19546 fixes #6982
* fixes #23536; Stack trace with wrong line number when the proc called inside ↵ringabout2024-04-262-6/+34
| | | | | for loop (#23540) fixes #23536