Skip to content

fix case warning with nim 0.20.0+ #4

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

Merged
merged 1 commit into from
Jul 23, 2019

Conversation

aguspiza
Copy link
Contributor

No description provided.

@gabearro
Copy link

Unpacking \xff\xff as an unsigned short doesn't produce 65535 as it should but rather produces -1 which is outside the range of a uint16 in nim.

example of issue:

import struct
import strutils

echo struct.unpack(">H", parseHexStr("FFFF"))[0].getUShort

stacktrace:

/.nimble/pkgs/struct-0.1.2/struct.nim(105) getUShort
/.choosenim/toolchains/nim-0.20.2/lib/system/fatal.nim(48) sysFatal
Error: unhandled exception: value out of range: -1 [RangeError]

@ba0f3
Copy link
Collaborator

ba0f3 commented Jul 23, 2019

I will check it soon

@gabearro
Copy link

I think a solution to -1 incorrectly becoming an unsigned short would be to give the proc load_16 another variable which would toggle whether to set the parameters a and b to int16 or uint16.

@ba0f3 ba0f3 merged commit ec1dd83 into OpenSystemsLab:master Jul 23, 2019
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 this pull request may close these issues.

3 participants