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

Disambiguating module of template call with shared symbol prevents building #23893

Closed
tersec opened this issue Jul 25, 2024 · 1 comment · Fixed by #23989
Closed

Disambiguating module of template call with shared symbol prevents building #23893

tersec opened this issue Jul 25, 2024 · 1 comment · Fixed by #23989

Comments

@tersec
Copy link
Contributor

tersec commented Jul 25, 2024

Description

c.nim:

type K* = object

s.nim:

import ./c
export c
template K*(kind: static int): auto = typedesc[c.K]
template B*(kind: static int): auto = typedesc[c.K]

p.nim:

import ./s
discard default(K(0))       # works
discard default(s.B(0))     # works
discard default(s.K(0))     # doesn't work

Nim Version

Nim Compiler Version 2.0.10 [Linux: amd64]
Compiled at 2024-07-25
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: 92e505577e8b6b9214b6fcdd7fe1b0e9a244023b
active boot switches: -d:release
Nim Compiler Version 2.1.9 [Linux: amd64]
Compiled at 2024-07-25
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: 469a6044c00ce657d2f543f292678b3c71e0b037
active boot switches: -d:release

Current Output

p.nim(4, 20) Error: type mismatch: got 'int literal(0)' for '0' but expected 'K = object'

Expected Output

That default(s.K(0)) builds if default(K(0)) and discard default(s.B(0)) build

Possible Solution

No response

Additional Information

No response

@tersec tersec changed the title Diisambiguating module of template call with shared symbol prevents building Disambiguating module of template call with shared symbol prevents building Jul 25, 2024
@metagn
Copy link
Collaborator

metagn commented Aug 20, 2024

The problem is that qualifiedLookUp directly looks up module symbols from the string table and doesn't set c.isAmbiguous = true if there are multiple symbols with the same name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants