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

Error message 'ambiguous identifier' shows wrong module for re-exported symbols #23397

Closed
simonkrauter opened this issue Mar 13, 2024 · 2 comments · Fixed by #24077
Closed

Error message 'ambiguous identifier' shows wrong module for re-exported symbols #23397

simonkrauter opened this issue Mar 13, 2024 · 2 comments · Fixed by #24077

Comments

@simonkrauter
Copy link
Contributor

simonkrauter commented Mar 13, 2024

Description

Minimal example:

File module1.nim:

const test* = "foo"

File module2.nim:

import module1
export test

File module3.nim:

const test* = "bar"

File main.nim:

import module2
import module3
echo test # this produces the error

The error message shows the module name where the test is originally defined (module1 and module3), but it show where it is imported (module2 and module3).

Nim Version

Nim Compiler Version 2.0.2 [Linux: amd64]

Current Output

Error: ambiguous identifier: 'test' -- use one of the following:
  module1.test: string
  module3.test: string

Expected Output

Error: ambiguous identifier: 'test' -- use one of the following:
  module2.test: string
  module3.test: string

Possible Solution

No response

Additional Information

No response

@quantimnot
Copy link
Contributor

I think #23123 broke this more. This is the result after commit b280100:

Error: type mismatch
Expression: echo test
  [1] test: string | string

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

This is way more confusing. @metagn

@metagn
Copy link
Collaborator

metagn commented Sep 7, 2024

I knew there was a different error message now given I disabled tpure_enums_conflict in #23123 but I didn't consider it completely obscures which symbols are ambiguous, I have an idea of what to do now but it's a bit verbose

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