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

passing 2 sets with 2 different ranges to a proc is not consistent #20142

Open
hamidb80 opened this issue Aug 3, 2022 · 2 comments
Open

passing 2 sets with 2 different ranges to a proc is not consistent #20142

hamidb80 opened this issue Aug 3, 2022 · 2 comments

Comments

@hamidb80
Copy link
Contributor

hamidb80 commented Aug 3, 2022

playground

Example

proc `==`[T](a, b: set[T]): bool =
  debugEcho (a.card, b.card)
  debugEcho (a, b)
  debugEcho "---" # <----- uncomment

  if a.card == b.card:
    for i in a:
      if i notin b:
        return false

    true

  else: false


when isMainModule:
  let
    s1: set['a' .. 'g'] = {'a', 'e'}
    # s2: set['a' .. 'g'] = {'b', 'c', 'd', 'f'} # this works fine
    s2 = {'b', 'c', 'd', 'f'}

  echo s1 == s2

Current Output

when line debugEcho "---" is not commented:

(2, 3)
({'a', 'e'}, {'f', 'g'})
---
false

when that line is commented:

(2, 2)
({'a', 'e'}, {'f'})
false

Additional Information

Nim Compiler Version 1.6.6 [Windows: amd64]
Compiled at 2022-05-05
Copyright (c) 2006-2021 by Andreas Rumpf

active boot switches: -d:release
@hamidb80 hamidb80 changed the title passing 2 sets with 2 different ranges to a proc is not consistent passing 2 sets with 2 different ranges to a proc is not consistent Aug 3, 2022
@hamidb80
Copy link
Contributor Author

hamidb80 commented Aug 3, 2022

@ringabout
Copy link
Member

Some related issues and prs:

#16270
#18388
#18396

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