sdl2_nim icon indicating copy to clipboard operation
sdl2_nim copied to clipboard

Exported converters cause havoc.

Open beef331 opened this issue 3 years ago • 4 comments

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
``

beef331 avatar Nov 18 '21 01:11 beef331

bef9a610a6bf53fba4cca231631603a3679b5b98 should help. Please check and let me know.

Vladar4 avatar Nov 20 '21 12:11 Vladar4

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

beef331 avatar Nov 21 '21 00:11 beef331

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

krux02 avatar Nov 21 '21 10:11 krux02