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

An exported converter, is silently exported by intermediate module #22416

Open
enthus1ast opened this issue Aug 8, 2023 · 2 comments
Open

An exported converter, is silently exported by intermediate module #22416

enthus1ast opened this issue Aug 8, 2023 · 2 comments

Comments

@enthus1ast
Copy link
Contributor

Description

An exported converter causes issues later in the import chain.
Even if the module a is not exported by b.nim it is still causing issues in c.nim

a.nim

converter toInt*(x: uint8): int = int(x)

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

b.nim

import a

c.nim

import b
echo 10'u8

Also see:

Vladar4/sdl2_nim#38
https://forum.nim-lang.org/t/8646#56246

Nim Version

Nim Compiler Version 2.0.0 [Linux: amd64]
Compiled at 2023-08-01
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: a488067
active boot switches: -d:release

Current Output

nim c -r c.nim 
Hint: used config file '/home/david/.choosenim/toolchains/nim-2.0.0/config/nim.cfg' [Conf]
Hint: used config file '/home/david/.choosenim/toolchains/nim-2.0.0/config/config.nims' [Conf]
Hint: used config file '/home/david/projects/nimPlayground/config.nims' [Conf]
........................................................................
/home/david/projects/nimPlayground/conv/b.nim(1, 8) Warning: imported and not used: 'a' [UnusedImport]
/home/david/projects/nimPlayground/conv/c.nim(2, 1) Error: type mismatch
Expression: echo 10'u8
  [1] 10'u8: uint8

Expected one of (first mismatch at [position]):
[1] proc echo(x: varargs[typed, `$`])

Expected Output

10

Possible Solution

No response

Additional Information

No response

@awr1
Copy link
Contributor

awr1 commented Aug 8, 2023

iirc converters are meant to be non-exportable. this is not mentioned in the manual but i recall some convo on IRC indicating this was the case.

@Araq
Copy link
Member

Araq commented Aug 10, 2023

Converters can be exported but the export rules are the same: A direct import makes the converter visible (and implicitly invokable) and an indirect import does not.

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

3 participants