nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.55k stars 1.47k forks source link

`type mismatch` error with pass through `import`/`export` with intermediate module also defining symbol #23497

Open tersec opened 6 months ago

tersec commented 6 months ago

Description

a.nim:

import "."/b
type H = b.E
discard H(default(F))

b.nim:

import "."/c
export c
type
  E* = object
  F* = b.E

c.nim:

type E* = object

And try to nim c a.

Nim Version

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

git hash: 19fdbfc173bfccb64cb64e0a963e69f52f71fc73
active boot switches: -d:release
Nim Compiler Version 2.0.4 [Linux: amd64]
Compiled at 2024-04-12
Copyright (c) 2006-2023 by Andreas Rumpf

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

git hash: 1bd095521856d4d1f9fb1b6ba580df3c815196f6
active boot switches: -d:release

Current Output

/root/a.nim(3, 10) Error: type mismatch:
 got 'E' for 'default(F)' [object declared in /root/b.nim(5, 3)]
 but expected 'E = Alias' [object declared in /root/c.nim(1, 6)]

Expected Output

Successful build

Possible Solution

No response

Additional Information

No response

metagn commented 6 months ago

So the problem is that H is c.E