| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
| |
ref https://github.com/nim-lang/Nim/pull/23226
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(#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.
```
|
|
|
|
|
| |
(#23558)
fixes #23552
|
| |
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
## 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.
|
|
|
|
|
| |
`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
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
|
| |
Reverts nim-lang/Nim#23566
ref
https://github.com/ba0f3/telebot.nim/commit/afe4ad877ec015091f5b6fde32ecb2502fe59a3f
|
| |
|
|
|
|
|
| |
fixes #23556
It should somehow handle default fields in the future
|
|
|
|
|
|
| |
Its doc used to render wrongly where `>` is considered as quote block:

|
|
|
|
|
|
|
|
|
| |
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
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`.
|
| |
|
|
|
|
|
| |
fixes #23531
fixes #19546
fixes #6982
|
|
|
|
|
| |
for loop (#23540)
fixes #23536
|
|
|
| |
fixes #23522
|
|
|
| |
fixes #23525
|
|
|
| |
ref https://github.com/nim-lang/Nim/issues/9550
|
|
|
|
|
|
|
|
|
|
|
|
| |
fixes #23524
```nim
proc isAnalysableFieldAccess*(orig: PNode; owner: PSym): bool =
...
result = n.kind == nkSym and n.sym.owner == owner and
{sfGlobal, sfThread, sfCursor} * n.sym.flags == {} and
(n.sym.kind != skParam or isSinkParam(n.sym))
```
In `isAnalysableFieldAccess`, globals, cursors are already rejected
|
|
|
|
| |
Previously, in certain cases, the compiler would generate debug info for
the correct line number, but for the wrong .nim source file.
|
| |
|
|
|
|
| |
inputLen may end up as 0 in the loop if the input string only includes
trailing characters. e.g. without the patch, decode(" ") would panic.
|
|
|
|
|
|
| |
This solution should resolve the nimsuggest crash issue. However,
perhaps the problem is in the parser?
fix #23518
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(#23388)
…instantiations (C/C++ backend)
AFAIK, #22802 expanded `noinit`'s utility by allowing the pragma to be
attached to types (thanks @jmgomez !).
I suggest broadening the scope a bit further: try to avoid `nimZeroMem`s
on a type level beyond imported C/C++ types[^1], saving us from
annotating the type instantiations with `noinit`.
If this change is deemed acceptable, I will also adjust the docs, of
course.
Adding tests for this change seems a bit problematic, as the effect of
this type annotation will be to work with uninitialized memory, which
*might* match 0 patterns.
[^1]: "complex value types" as already defined here:
https://github.com/nim-lang/Nim/blob/94c599687796f4ee3872c8aa866827b9ed33f52b/compiler/cgen.nim#L470-L471
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When forward declaration is used with pragmas `virtual` or `member`, the
declaration in struct is added twice. It happens because of missing
check for `sfWasForwarded` pragma.
Current compiler generates the following C++ code:
```cpp
struct tyObject_Foo__fFO9b6HU7kRnKB9aJA1RApKw {
N_LIB_PRIVATE N_NOCONV(void, abc)(NI x_p1);
N_LIB_PRIVATE N_NOCONV(virtual void, def)(NI y_p1);
N_LIB_PRIVATE N_NOCONV(void, abc)(NI x_p1);
N_LIB_PRIVATE N_NOCONV(virtual void, def)(NI y_p1);
};
```
|
|
|
|
|
|
|
| |
workaround #23435
related to https://github.com/nim-lang/Nim/issues/22852
see also #23279
|
|
|
|
| |
pending https://github.com/nim-lang/atlas/pull/119
pending AtlasStableCommit updates
|
|
|
|
| |
follow up https://github.com/nim-lang/Nim/pull/7606
https://github.com/nim-lang/Nim/pull/13466
|
|
|
| |
introduced in https://github.com/nim-lang/Nim/pull/9411
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
fixes #23492
```nim
proc foo =
var x: range[1.0 .. 5.0] = 2.0
case x
of 1.0..2.0:
echo 1
else:
echo 3
foo()
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
fixes #4695
ref https://github.com/nim-lang/Nim/pull/15818
Since `nkState` is only for the main loop state labels and `nkGotoState`
is used only for dispatching the `:state` (since
https://github.com/nim-lang/Nim/pull/7770), it's feasible to rewrite the
loop body into a single case-based dispatcher, which enables support for
JS, VM backend. `nkState` Node is replaced by a label and Node pair and
`nkGotoState` is only used for intermediary processing. Backends only
need to implement `nkBreakState` and `closureIterSetupExc` to support
closure iterators.
pending https://github.com/nim-lang/Nim/pull/23484
<del> I also observed some performance boost for C backend in the
release mode (not in the danger mode though, I suppose the old
implementation is optimized into computed goto in the danger mode)
</del>
allPathsAsgnResult???
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Because `isGitRepo()` call requires `/bin/sh` it will always fail when
building Nim in a Nix build sandbox, and the check doesn't even make
sense if Nix already provides Nimble source code.
Since for Nimble `allowBundled` is set to `true` this effectlvely does
not change behavior for normal builds, but does avoid ugly hacks when
building in Nix which lacks `/bin/sh` and fails to call `git`.
Reference:
*
https://github.com/status-im/nimbus-eth2/pull/6180#discussion_r1570237858
Signed-off-by: Jakub Sokołowski <jakub@status.im>
|
|
|
|
|
| |
refs (#23507)
fixes #23505
|
|
|
|
|
| |
Was introduced to handle a break in #23392, according to
https://github.com/nim-lang/Nim/pull/23503#issuecomment-2057266475
should not be needed anymore
|
|
|
| |
fixes #23494
|
|
|
|
|
|
|
|
|
|
|
| |
fixes #23499
In the
https://github.com/nim-lang/Nim/commit/8990626ca9715a3687b28331aee4ccf242997aa2
the effect of `skipAddr` changed to skip `nkAddr` and `nkHiddenAddr`.
Some old code was not adapted. In the
https://github.com/nim-lang/Nim/pull/23477, the magic `addr` function
was handled in the semantic analysis phase, which causes it be skipped
incorrectly
|
|
|
|
|
| |
(#23501)
…he compiler
|
|
|
|
|
| |
fixes #23487
uses JSRef
|
|
|
|
|
|
|
|
|
|
| |
variable `_` (#23498)
According to
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/Expression_statement,
some expression statements need parentheses to make it unambiguous. `_`
introduced in the https://github.com/nim-lang/Nim/pull/15789 is
unnecessary. We can get rid of it by adding parentheses so that object
literals are not ambiguous with block statements.
|
|
|
|
|
|
| |
Hi,
This is a tiny change, fixing the error in the documentation of JSON's
deep copy proc.
|
|
|
|
|
|
|
|
| |
fixes #4299
fixes #12492
fixes #10849
It binds `function` with `env`: `function.bind(:env)` to ease codegen
for now
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Added a second example inside the `typedthreads` file.
Also, add a more detailed introduction. When Nim is one's first
programming language, a short explanation of what a thread is might not
hurt.
For reference, the thread documentation of other languages looks like
this:
- https://en.cppreference.com/w/cpp/thread/thread
- https://doc.rust-lang.org/std/thread/
The documentation of a module is the first place one will look when
using a standard library feature, so I think it is important to have a
few usable examples for the main modules.
This is the example added
```nim
import locks
var l: Lock
proc threadFunc(obj: ptr seq[int]) {.thread.} =
withLock l:
for i in 0..<100:
obj[].add(obj[].len * obj[].len)
proc threadHandler() =
var thr: array[0..4, Thread[ptr seq[int]]]
var s = newSeq[int]()
for i in 0..high(thr):
createThread(thr[i], threadFunc, s.addr)
joinThreads(thr)
echo s
initLock(l)
threadHandler()
deinitLock(l)
```
Sharing memory between threads is very very common, so I think having an
example showcasing this is crucial.
---------
Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
|
| |
|