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

Erroneous Set datatype behavior #21315

Closed
rodabt opened this issue Apr 19, 2024 · 0 comments · Fixed by #21362
Closed

Erroneous Set datatype behavior #21315

rodabt opened this issue Apr 19, 2024 · 0 comments · Fixed by #21362
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Modules: datatypes Bugs/feature requests, that are related to the `datatypes` module.

Comments

@rodabt
Copy link
Contributor

rodabt commented Apr 19, 2024

Describe the bug

Two identical Set[string]{} x and y give different results when y - x after x - y

Reproduction Steps

// V 0.4.5 2baa11b
import datatypes { Set }

fn main() {
    m := ['a','b','c']
    n := ['a','b','c']
    assert m == n
    mut set_m := Set[string]{}
    mut set_n := Set[string]{}
    set_m.add_all(m)
    set_n.add_all(n)
    assert set_m == set_n
    diff1 := set_m - set_n
    diff2 := set_n - set_m
    println(diff1)
    println(diff2)
    // Should be identical...but not
    assert diff1 == diff2
}

Expected Behavior

assert diff1 == diff2 should be true

Current Behavior

Throws error in assert

datatypes.Set[string]{
    elements: {}
}
datatypes.Set[string]{
    elements: {'a': 1, 'b': 1, 'c': 1}
}
tmp3.v:21: FAIL: fn main.main: assert diff1 == diff2
   left value: diff1 = datatypes.Set[string]{
    elements: {}
}
  right value: diff2 = datatypes.Set[string]{
    elements: {'a': 1, 'b': 1, 'c': 1}
}
V panic: Assertion failed...
v hash: 2baa11b
/tmp/v_1000/tmp3.01HVW16R04A9R3CBS3NG9H8D1N.tmp.c:7202: at _v_panic: Backtrace
/tmp/v_1000/tmp3.01HVW16R04A9R3CBS3NG9H8D1N.tmp.c:13607: by main__main
/tmp/v_1000/tmp3.01HVW16R04A9R3CBS3NG9H8D1N.tmp.c:13648: by main

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.5 2baa11b

Environment details (OS name and version, etc.)

V full version: V 0.4.5 2baa11b
OS: linux, Debian GNU/Linux 11 (bullseye) (WSL 2)
Processor: 8 cpus, 64bit, little endian, Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz

getwd: /home/rabt/devel/prisma2/OLD/tmp
vexe: /home/rabt/devel/v/v
vexe mtime: 2024-04-19 20:34:45

vroot: OK, value: /home/rabt/devel/v
VMODULES: OK, value: /home/rabt/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.30.2
Git vroot status: 0.4.5-203-g2baa11b3
.git/config present: true

CC version: cc (Debian 10.2.1-6) 10.2.1 20210110
thirdparty/tcc status: thirdparty-linux-amd64 40e5cbb5

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@rodabt rodabt added the Bug This tag is applied to issues which reports bugs. label Apr 19, 2024
@felipensp felipensp added the Modules: datatypes Bugs/feature requests, that are related to the `datatypes` module. label Apr 27, 2024
@felipensp felipensp self-assigned this Apr 27, 2024
spytheman pushed a commit that referenced this issue May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. Modules: datatypes Bugs/feature requests, that are related to the `datatypes` module.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants