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

proc with generic params spuriously disambiguating different types with same name across imported modules #23510

Open
tersec opened this issue Apr 17, 2024 · 0 comments

Comments

@tersec
Copy link
Contributor

tersec commented Apr 17, 2024

Description

m.nim:

import ./j
import ./e

proc u(d: int | int) =
  var r: Y
  static: doAssert r is j.Y  # because j is imported first
  doAssert r is j.Y

u(0)

j.nim and e.nim:

type Y* = object

nim c m

Nim Version

Nim Compiler Version 1.6.21 [Linux: amd64]
Compiled at 2024-04-17
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: 8ebb4dc30af3a5d3dd14bc651698d02b715befed
active boot switches: -d:release
Nim Compiler Version 2.0.5 [Linux: amd64]
Compiled at 2024-04-17
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: 3ad16028aae82aa7cc48e72744890dd3fe504796
active boot switches: -d:release
Nim Compiler Version 2.1.1 [Linux: amd64]
Compiled at 2024-04-17
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: 49e1ca0b3e53709b993f63288a164cd843c70c82
active boot switches: -d:release

Current Output

Builds with
m.nim(2, 8) Warning: imported and not used: 'e' [UnusedImport]

Expected Output

Does not build, because it does not have enough information to disambiguate which Y symbol it should use. Replacing proc with template, or with a non-generic proc, shows

m.nim(5, 10) Error: ambiguous identifier: 'Y' -- use one of the following:
  j.Y: Y
  e.Y: Y

Possible Solution

No response

Additional Information

No response

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

No branches or pull requests

2 participants