Commits on Dec 8, 2024

  1. bump NimVersion to 2.0.13

    narimiran committed Dec 8, 2024
    Configuration menu
    Copy the full SHA
    9f43f9f View commit details
    Browse the repository at this point in the history
  2. fixes #24504; fixes ensureMove for refs (#24505)

    fixes #24504
    
    (cherry picked from commit d0288d3)
    ringabout authored and narimiran committed Dec 8, 2024
    Configuration menu
    Copy the full SHA
    15e5ddc View commit details
    Browse the repository at this point in the history

Commits on Dec 9, 2024

  1. install older version of nimcuda for arraymancer (#24496)

    Attempt to fix CI failure, refs
    #24495 (comment),
    alternative is to use a commit version like
    SciNim/nimcuda@bc65375
    
    (cherry picked from commit 33dc236)
    metagn authored and narimiran committed Dec 9, 2024
    Configuration menu
    Copy the full SHA
    90993ae View commit details
    Browse the repository at this point in the history

Commits on Dec 12, 2024

  1. fixes #22153; UB calling allocCStringArray([""]) with --mm:refc (#24529)

    fixes #22153
    
    It's a problem for refc because you cannot index a nil string: i.e.
    `[""]` is `{((NimStringDesc*) NIM_NIL)}` which cannot be indexed
    
    (cherry picked from commit 9bb7e53)
    ringabout authored and narimiran committed Dec 12, 2024
    Configuration menu
    Copy the full SHA
    f6f7272 View commit details
    Browse the repository at this point in the history

Commits on Dec 13, 2024

  1. Bumps nimble v0.16.4 (#24437)

    (cherry picked from commit be4d19e)
    jmgomez authored and narimiran committed Dec 13, 2024
    Configuration menu
    Copy the full SHA
    1778b83 View commit details
    Browse the repository at this point in the history

Commits on Dec 16, 2024

  1. (cherry picked from commit 556f217)

    jmgomez authored and narimiran committed Dec 16, 2024
    Configuration menu
    Copy the full SHA
    9e5cdc4 View commit details
    Browse the repository at this point in the history
  2. Revert "(cherry picked from commit 556f217)"

    This reverts commit 9e5cdc4.
    narimiran committed Dec 16, 2024
    Configuration menu
    Copy the full SHA
    9620d20 View commit details
    Browse the repository at this point in the history
  3. Revert "Bumps nimble v0.16.4 (#24437)"

    This reverts commit 1778b83.
    narimiran committed Dec 16, 2024
    Configuration menu
    Copy the full SHA
    dbe9c72 View commit details
    Browse the repository at this point in the history
  4. fixes #23233; Regression when using generic type with Table/OrderedTa…

    …ble (#23235)
    
    fixes #23233
    
    (cherry picked from commit 7200219)
    ringabout authored and narimiran committed Dec 16, 2024
    Configuration menu
    Copy the full SHA
    3a334e0 View commit details
    Browse the repository at this point in the history
  5. fixes #18104; tranform one liner var decl before templates expansion (#…

    …23294)
    
    fixes #18104
    
    (cherry picked from commit 1e9a3c4)
    ringabout authored and narimiran committed Dec 16, 2024
    Configuration menu
    Copy the full SHA
    4e1b5ee View commit details
    Browse the repository at this point in the history
  6. fixes #23295; don't expand constants for complex structures (#23297)

    fixes #23295
    
    (cherry picked from commit 39f2df1)
    ringabout authored and narimiran committed Dec 16, 2024
    Configuration menu
    Copy the full SHA
    0c426e7 View commit details
    Browse the repository at this point in the history
  7. fixes 12381, HttpClient socket handle leak (#23575)

    ## Bug
    
    Fixes #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.
    
    (cherry picked from commit e6f66e4)
    mariusandra authored and narimiran committed Dec 16, 2024
    Configuration menu
    Copy the full SHA
    6a1d1a8 View commit details
    Browse the repository at this point in the history
  8. Check for nil in cstringArrayToSeq (#23747)

    This fixes crashes in some specific network configurations (as
    `cstringArrayToSeq` is used extensively in `nativesockets`).
    
    ---------
    
    Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
    (cherry picked from commit 2c83f94)
    2 people authored and narimiran committed Dec 16, 2024
    Configuration menu
    Copy the full SHA
    33dc54c View commit details
    Browse the repository at this point in the history
  9. Set type of object constructor during annotateType (#23852)

    Fix #23547
    
    Tested locally with the included test, the test from constantine and the
    original issue.
    
    (cherry picked from commit f765898)
    SirOlaf authored and narimiran committed Dec 16, 2024
    Configuration menu
    Copy the full SHA
    c786415 View commit details
    Browse the repository at this point in the history
  10. bypass constraints for tyFromExpr in generic bodies (#23863)

    fixes #19819, fixes #23339
    
    Since #22029 `tyFromExpr` does not match anything in overloading, so
    generic bodies can know which call expressions to delay until the type
    can be evaluated. However generic type invocations also run overloading
    to check for generic constraints even in generic bodies. To prevent them
    from failing early from the overload not matching, pretend that
    `tyFromExpr` matches. This mirrors the behavior of the compiler in more
    basic cases like:
    
    ```nim
    type
      Foo[T: int] = object
        x: T
      Bar[T] = object
        y: Foo[T]
    ```
    
    Unfortunately this case doesn't respect the constraint (#21181, some
    other bugs) but `tyFromExpr` should easily use the same principle when
    it does.
    
    (cherry picked from commit 31ee75f)
    metagn authored and narimiran committed Dec 16, 2024
    Configuration menu
    Copy the full SHA
    009a5b0 View commit details
    Browse the repository at this point in the history
  11. include generic bodies in allowMetaTypes (#23968)

    fixes #19848
    
    Not sure why this wasn't the case already. The `if cl.allowMetaTypes:
    return` line below for `tyFromExpr` [was added 10 years
    ago](d5798b4).
    Hopefully it was just negligence?
    
    (cherry picked from commit 1befb8d)
    metagn authored and narimiran committed Dec 16, 2024
    Configuration menu
    Copy the full SHA
    ba516c8 View commit details
    Browse the repository at this point in the history
  12. fix subscript magic giving unresolved generic param type (#23988)

    fixes #19737
    
    As in the diff, `semResolvedCall` sets the return type of a call to a
    proc to the type of the call. But in the case of the [subscript
    magic](https://nim-lang.org/docs/system.html#%5B%5D%2CT%2CI), this type
    is the first generic param which is also supposed to be the type of the
    first argument, but this is invalid, the correct type is the element
    type eventually given by `semSubscript`. Some lines above also [prevent
    the subscript magics from instantiating their
    params](https://github.com/nim-lang/Nim/blob/dda638c1ba985a77eac3c7518138992521884172/compiler/semcall.nim#L699)
    so this type ends up being an unresolved generic param.
    
    Since the type of the node is not `nil`, `prepareOperand` doesn't try to
    type it again, and this unresolved generic param type ends up being the
    final type of the node. To prevent this, we just never set the type of
    the node if we encountered a subscript magic.
    
    Maybe we could also rename the generic parameters of the subscript
    magics to stuff like `DummyT`, `DummyI` if we want this to be easier to
    debug in the future.
    
    (cherry picked from commit 04da0a6)
    metagn authored and narimiran committed Dec 16, 2024
    Configuration menu
    Copy the full SHA
    0e2b34c View commit details
    Browse the repository at this point in the history
  13. fixes #24034; fixes lent types after taking implicit address (#24035)

    fixes #24034
    
    (cherry picked from commit 11ead19)
    ringabout authored and narimiran committed Dec 16, 2024
    Configuration menu
    Copy the full SHA
    8859f1d View commit details
    Browse the repository at this point in the history
  14. fix undeclared identifier in templates in generics (#24069)

    fixes #13979
    
    Fixes templates in generics that use identifiers that aren't defined
    yet, giving an early `undeclared identifier` error, by just marking
    template bodies as in a mixin context in `semgnrc`.
    
    (cherry picked from commit bf865fa)
    metagn authored and narimiran committed Dec 16, 2024
    Configuration menu
    Copy the full SHA
    4d0d848 View commit details
    Browse the repository at this point in the history
  15. fix string literal assignment with different lengths on ARC (#24083)

    fixes #24080
    
    (cherry picked from commit cd22560)
    metagn authored and narimiran committed Dec 16, 2024
    Configuration menu
    Copy the full SHA
    d51236e View commit details
    Browse the repository at this point in the history
  16. fix int32's that should be uint32 on BSD & OSX (#24078)

    fixes #24076
    
    As described in #24076, misannotating these types causes codegen errors.
    Sources for the types are https://github.com/openbsd/src/blob/master/sys
    for BSD and https://opensource.apple.com/source/Libinfo/Libinfo-391/ and
    [_types.h](https://opensource.apple.com/source/xnu/xnu-1456.1.26/bsd/sys/_types.h.auto.html)
    for OSX.
    
    (cherry picked from commit 7de4ace)
    metagn authored and narimiran committed Dec 16, 2024
    Configuration menu
    Copy the full SHA
    56e7c75 View commit details
    Browse the repository at this point in the history
  17. fix regression with generic params in static type (#24075)

    Caught in https://github.com/metagn/applicates, I'm not sure which
    commit causes this but it's also in the 2.0 branch (but not 2.0.2), so
    it's not any recent PRs.
    
    If a proc has a static parameter with type `static Foo[T]`, then another
    parameter with type `static Bar[T, U]`, the generic instantiation for
    `Bar` doesn't match `U` which has type `tyGenericParam`, but matches `T`
    since it has type `tyTypeDesc`. The reason is that `concreteType`
    returns the type itself for `tyTypeDesc` if `c.isNoCall` (i.e. matching
    a generic invocation), but returns `nil` for `tyGenericParam`. I'm
    guessing `tyGenericParam` is received here because of #22618, but that
    doesn't explain why `T` is still `tyTypeDesc`. I'm not sure.
    
    Regardless, we can just copy the behavior for `tyTypeDesc` to
    `tyGenericParam` and also return the type itself when `c.isNoCall`. This
    feels like it defeats the purpose of `concreteType` but the way it's
    used doesn't make sense without it (generic param can't match another
    generic param?). Alternatively we could loosen the `if concrete == nil:
    return isNone` checks in some places for specific conditions, whether
    `c.isNoCall` or `c.inGenericContext == 0` (though this would need
    
    (cherry picked from commit 24e5b21)
    metagn authored and narimiran committed Dec 16, 2024
    Configuration menu
    Copy the full SHA
    5cbc7a6 View commit details
    Browse the repository at this point in the history
  18. only generate first field for default value of union (#24303)

    fixes #20653
    
    (cherry picked from commit 6df050d)
    metagn authored and narimiran committed Dec 16, 2024
    Configuration menu
    Copy the full SHA
    f45ca4f View commit details
    Browse the repository at this point in the history

Commits on Dec 17, 2024

  1. fixes #24319; move doesn't work well with (deref (var array)) (#24321)

    fixes #24319
    
    `byRefLoc` (`mapType`) requires the Loc `a` to have the right type.
    Without `lfEnforceDeref`, it produces the wrong type for `deref (var
    array)`, which may come from `mitems`.
    
    (cherry picked from commit 0347536)
    ringabout authored and narimiran committed Dec 17, 2024
    Configuration menu
    Copy the full SHA
    1f38c3c View commit details
    Browse the repository at this point in the history
  2. Fix broken poll and nfds_t bindings (#24331)

    This fixes several cases of the Nim binding of nfds_t being inconsistent
    with the target platform signedness and/or size.
    
    Additionally, it fixes poll's third argument (timeout) being set to Nim
    "int" when it should have been "cint".
    
    The former is the same issue that #23045 had attempted to fix, but
    failed because it only considered Linux. (Also, it was only applied to
    version 2.0, so the two branches now have incompatible versions of the
    same bug.)
    
    Notes:
    
    * SVR4's original "unsigned long" definition is cloned by Linux and
    Haiku. Nim got this right for Haiku and Linux-amd64, but it was wrong on
    non-amd64 Linux.
    * Zephyr does not have nfds_t, but simply uses (signed) "int". This was
    already correctly reflected by Nim.
    * OpenBSD poll.h uses "unsigned int", and other BSD derivatives follow
    suit. This being the most commonly copied definition, the fallback case
    now returns cuint. (This also seems to be correct for the OS X headers I
    could find on the web.)
    * This changes Nintendo Switch nfds_t to cuint from culong. It is
    purportedly a FreeBSD derivative, so I *think* this is correct, but I
    can't tell because I don't have access to the Nintendo Switch headers.
    
    I have also moved the platform-specific Tnfds to posix.nim so that we
    can reuse the fallback logic on all platforms. (e.g. specifying the size
    in posix_linux_amd64 only to then use when defined(linux) in posix_other
    seems redundant.)
    
    (cherry picked from commit 6744247)
    bptato authored and narimiran committed Dec 17, 2024
    Configuration menu
    Copy the full SHA
    c1bb144 View commit details
    Browse the repository at this point in the history
  3. fixes #23545; C compiler error when default initializing an object fi…

    …eld function (#24375)
    
    fixes #23545
    
    (cherry picked from commit 815bbf0)
    ringabout authored and narimiran committed Dec 17, 2024
    Configuration menu
    Copy the full SHA
    693b35b View commit details
    Browse the repository at this point in the history
  4. fixes #24371; incorrect importc wrapper incompatible with gcc 14 on W…

    …indows (#24388)
    
    fixes #24371
    
    (cherry picked from commit 74df699)
    ringabout authored and narimiran committed Dec 17, 2024
    Configuration menu
    Copy the full SHA
    d84d41d View commit details
    Browse the repository at this point in the history
  5. gensym anonymous proc symbols (#24422)

    fixes #14067, fixes #15004, fixes #19019
    
    Anonymous procs are [added to
    scope](https://github.com/nim-lang/Nim/blob/8091d76306c23b866af00d384b9b6f929ef8ed23/compiler/semstmts.nim#L2466)
    with the name `:anonymous`. This means that if they have the same
    signature in a scope, they can consider each other as redefinitions. To
    prevent this, mark their symbols as `sfGenSym` so they do not get added
    to scope or cause any name conflicts. The commented out `and not isAnon`
    check wouldn't work because `isAnon` would not be true if the proc is
    being resemmed, in which case the name field in the proc AST would have
    the symbol of the anonymous proc rather than being empty.
    
    There is a separate problem of default values in generic/normal procs
    not opening new scopes which is partially responsible for #19019.
    
    (cherry picked from commit 3e47725)
    metagn authored and narimiran committed Dec 17, 2024
    Configuration menu
    Copy the full SHA
    5327498 View commit details
    Browse the repository at this point in the history
  6. fix crash with tyBuiltInTypeClass matching itself (#24462)

    fixes #24449
    
    The standalone `seq` type is a `tyBuiltInTypeClass` with a single child
    of kind `tySequence`, which itself has no children. This is also the
    case for most other `tyBuiltInTypeClass` kinds. However this can cause a
    crash in sigmatch when calling `isEmptyContainer` on this child type,
    which expects the sequence type to have children. This check was added
    in #5557 to prevent empty collections like `@[]` from matching their
    respective typeclass, but it's not useful when matching against another
    typeclass (which is done here to resolve an ambiguity). So to avoid the
    crash, this empty container check is disabled when matching against
    another typeclass.
    
    (cherry picked from commit 96043bd)
    metagn authored and narimiran committed Dec 17, 2024
    Configuration menu
    Copy the full SHA
    5c58e7d View commit details
    Browse the repository at this point in the history
  7. Fix exitnow signature, mark as .noreturn (#24533)

    Like quit, this function never returns.
    
    Also, "code" was marked as "int", even though POSIX _exit takes a C int.
    
    (cherry picked from commit f485973)
    bptato authored and narimiran committed Dec 17, 2024
    Configuration menu
    Copy the full SHA
    6bcb078 View commit details
    Browse the repository at this point in the history

Commits on Dec 20, 2024

  1. make distinct conversions addressable in VM (#24124)

    fixes #24097
    
    For `nkConv` addresses where the conversion is between 2 types that are
    equal between backends, treat assignments the same as assignments to the
    argument of the conversion. In the VM this seems to be in `genAsgn` and
    `genAsgnPatch`, as evidenced by the special logic for `nkDerefExpr` etc.
    
    This doesn't handle ranges after #24037 because `sameBackendType` is
    used and not `sameBackendTypeIgnoreRange`. This is so this is
    backportable without #24037 and another PR can be opened that implements
    it for ranges and adds tests as well. We can also merge
    `sameBackendTypeIgnoreRange` with `sameBackendType` since it doesn't
    seem like anything that uses it would be affected (only cycle checks and
    the VM), but then we still have to add tests.
    
    (cherry picked from commit 1fbb67f)
    metagn authored and narimiran committed Dec 20, 2024
    Configuration menu
    Copy the full SHA
    95fa7f0 View commit details
    Browse the repository at this point in the history
  2. fix logic for dcEqIgnoreDistinct in sameType (#24197)

    fixes #22523
    
    There were 2 problems with the code in `sameType` for
    `dcEqIgnoreDistinct`:
    
    1. The code that skipped `{tyDistinct, tyGenericInst}` only ran if the
    given types had different kinds. This is fixed by always performing this
    skip.
    2. The code block below that checks if `tyGenericInst`s have different
    values still ran for `dcEqIgnoreDistinct` since it checks if the given
    types are generic insts, not the skipped types (and also only the 1st
    given type). This is fixed by only invoking this block for `dcEq`;
    `dcEqOrDistinctOf` (which is unused) also skips the first given type.
    Arguably there is another issue here that `skipGenericAlias` only ever
    skips 1 type.
    
    These combined fix the issue (`T` is `GenericInst(V, 1, distinct int)`
    and `D[0]` is `GenericInst(D, 0, distinct int)`).
    
    (cherry picked from commit b0e6d28)
    metagn authored and narimiran committed Dec 20, 2024
    Configuration menu
    Copy the full SHA
    5355568 View commit details
    Browse the repository at this point in the history
  3. fixes #18081; fixes #18079; fixes #18080; nested ref/deref'd types (#…

    …24335)
    
    fixes #18081;
    fixes #18080
    fixes #18079
    
    reverts #20738
    
    It is probably more reasonable to use the type node from `nkObjConstr`
    since it is barely changed unlike the external type, which is
    susceptible to code transformation e.g. `addr(deref objconstr)`.
    
    (cherry picked from commit aa90d00)
    ringabout authored and narimiran committed Dec 20, 2024
    Configuration menu
    Copy the full SHA
    5fb4662 View commit details
    Browse the repository at this point in the history
  4. fixes #24472; let symbol created by template is reused in nimvm branch (

    #24473)
    
    fixes #24472
    
    Excluding variables which are initialized in the nimvm branch so that
    they won't interfere the other branch
    
    (cherry picked from commit e7f48cd)
    ringabout authored and narimiran committed Dec 20, 2024
    Configuration menu
    Copy the full SHA
    14dfabb View commit details
    Browse the repository at this point in the history
  5. Bumps nimble v0.16.4 (#24437)

    (cherry picked from commit be4d19e)
    jmgomez authored and narimiran committed Dec 20, 2024
    Configuration menu
    Copy the full SHA
    30abe60 View commit details
    Browse the repository at this point in the history
  6. (cherry picked from commit 556f217)

    jmgomez authored and narimiran committed Dec 20, 2024
    Configuration menu
    Copy the full SHA
    76935b4 View commit details
    Browse the repository at this point in the history
  7. Adds skipParentCfg back. Bump nimble to a commit where it doesnt …

    …rely in the parent config (#24545)
    
    (cherry picked from commit 8ce58fa)
    jmgomez authored and narimiran committed Dec 20, 2024
    Configuration menu
    Copy the full SHA
    8f44c40 View commit details
    Browse the repository at this point in the history

Commits on Dec 23, 2024

  1. fixes #24536; fixes nightlies regression caused by nimble update (#24542

    )
    
    follow up #24537
    
    Because `nimble` is a bundled repo so it is bundled in the tarballs
    
    i.e.
    https://github.com/nim-lang/nightlies/blob/82421fd7053bf58dea69e9a259e6f2618c2be2e5/.github/workflows/nightlies.yml#L264
    has bundled `dist/nimble`, but it only copies the data without `.git`.
    So in this PR, we ignore bundled nimble repo.
    
    (cherry picked from commit 70b3232)
    ringabout authored and narimiran committed Dec 23, 2024
    Configuration menu
    Copy the full SHA
    c7d057d View commit details
    Browse the repository at this point in the history
  2. remove zippy data from tarballs (#24551)

    fixes nim-lang/nightlies#95
    
    (cherry picked from commit 63c8840)
    ringabout authored and narimiran committed Dec 23, 2024
    Configuration menu
    Copy the full SHA
    86f1a27 View commit details
    Browse the repository at this point in the history
  3. bump NimVersion to 2.0.14

    narimiran committed Dec 23, 2024
    Configuration menu
    Copy the full SHA
    bf4de6a View commit details
    Browse the repository at this point in the history