Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lent support makes tryGet returns the wrong value #50

Closed
2-towns opened this issue Dec 6, 2024 · 1 comment
Closed

lent support makes tryGet returns the wrong value #50

2-towns opened this issue Dec 6, 2024 · 1 comment

Comments

@2-towns
Copy link

2-towns commented Dec 6, 2024

I am trying to update Codex and its sub-dependencies to Nim version 2.x (currently testing with 2.0.12), and I found an error with nim-results that has lent support when running the tests on the nim-datastore repository. The tryGet method returns the wrong value. Here is the part of the test that is failing:

    let
      key = Key.init("/a:b/c/d:e").tryGet()
    echo key.parent
    # success(/a:b/c)
    echo key.parent.tryGet()
    # /a:b/c
    echo key.parent.?parent
    # success(/a:b)
    echo key.parent.?parent.tryGet()
    # /a:a  
    # Expected: /a:b

It works with the previous before the lent support (commit hash bf8a958).
I tried to look at the code and found something that may be related:

# TODO https://github.com/nim-lang/Nim/issues/22216

The tests output are:

==========
  /home/share/arnaud/Work/codex/nim-datastore/tests/testall 'Key::key parent'
----------
    /home/share/arnaud/Work/codex/nim-datastore/tests/datastore/testkey.nim(249, 34): Check failed: key.parent .? parent.tryGet() == Key.init("a:b").tryGet()
    key.parent .? parent.tryGet() was /
    Key.init("a:b").tryGet() was /a:b

  [FAILED ] (  0.00s) key parent

========
  /home/share/arnaud/Work/codex/nim-datastore/tests/testall 'Key::key path'
--------
    /home/share/arnaud/Work/codex/nim-datastore/tests/datastore/testkey.nim(258, 30): Check failed: key.parent .? path.tryGet == Key.init("a:b/c").tryGet()
    key.parent .? path.tryGet was //
    Key.init("a:b/c").tryGet() was /a:b/c
    /home/share/arnaud/Work/codex/nim-datastore/tests/datastore/testkey.nim(260, 41): Check failed: Key.init("a:b/c:d") .? path.tryGet() == Key.init("a:b/c").tryGet()
    Key.init("a:b/c:d") .? path.tryGet() was //
    Key.init("a:b/c").tryGet() was /a:b/c
    /home/share/arnaud/Work/codex/nim-datastore/tests/datastore/testkey.nim(261, 43): Check failed: Key.init("a:b/c/d:e") .? path.tryGet() == Key.init("a:b/c/d").tryGet()
    Key.init("a:b/c/d:e") .? path.tryGet() was ///
    Key.init("a:b/c/d").tryGet() was /a:b/c/d

  [FAILED ] (  0.00s) key path

The failing tests are located at https://github.com/codex-storage/nim-datastore/blob/b3d4bd40fc4e45a76aa4e3b6d9aa3a2d064fc6b1/tests/datastore/testkey.nim#L233 and https://github.com/codex-storage/nim-datastore/blob/b3d4bd40fc4e45a76aa4e3b6d9aa3a2d064fc6b1/tests/datastore/testkey.nim#L256.

@arnetheduck
Copy link
Owner

df8113d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants