Vladar4 / sdl2_nim

Wrapper of the SDL 2 library for the Nim language.
Other
147 stars 24 forks source link

Exported converters cause havoc. #38

Open beef331 opened 2 years ago

beef331 commented 2 years ago

I just spent 10-20 minutes to hunt down why I could not echo a byte, which is cause of https://github.com/Vladar4/sdl2_nim/blob/43bbdb99e01aa3d2117fc536dd6b0ed3280791a9/sdl2_nim/private/stdinc.nim#L87. This should be behind a flag or removed in my view. To see the fun error message you get due to it consider the following.


converter toInt*(x: uint8): int = int(x)
echo 10u8
``
Vladar4 commented 2 years ago

bef9a610a6bf53fba4cca231631603a3679b5b98 should help. Please check and let me know.

beef331 commented 2 years ago

That will not resolve the issue as converters bubble up. For example the following still errors.

# Module c
converter toInt*(x: uint8): int = int(x)
proc `$`*(x: uint8): string {.raises: [].} =
  result.addInt(int(x))

# Module b
import c

# Module a
import b
echo 10u8
krux02 commented 2 years ago

looks to me like a Nim bug that needs a workaround.

Vladar4 commented 2 years ago

Confirmed regression