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

compile-time int conversion fails in when false section #24041

Closed
arnetheduck opened this issue Sep 1, 2024 · 0 comments · Fixed by #24042
Closed

compile-time int conversion fails in when false section #24041

arnetheduck opened this issue Sep 1, 2024 · 0 comments · Fixed by #24042

Comments

@arnetheduck
Copy link
Contributor

Description

type ArrayBuf*[N: static int, T = byte] = object
  when sizeof(int) > sizeof(uint8):
    when N <= int(uint8.high):
      n*: uint8
    else:
      when sizeof(int) > sizeof(uint16):
        when N <= int(uint16.high):
          n*: uint16
        else:
          when sizeof(int) > sizeof(uint32):
            when N <= int(uint32.high):
              n*: uint32
            else:
              n*: int
          else:
            n*: int
      else:
        n*: int
  else:
    n*: int

in 32-bit mode, the section when sizeof(int) > sizeof(uint32) should not be entered, and yet the compiler complains about when N <= int(uint32.high)

Nim Version

2.0.8

Current Output

nim c -r  --cpu:i386 "testit.nim"

/home/arnetheduck/status/nimbus-eth1/_exper/testit.nim(12, 26) Error: cannot convert 4294967295 to int

Expected Output

No response

Known Workarounds

No response

Additional Information

No response

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

Successfully merging a pull request may close this issue.

1 participant