You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
type
testing*=object
z: intprocfoo*(t: testing) =echo"doink!"
c.nim
import a, b
var x: testing
x.foo
If you then compile c, this results in an error like:
c.nim(4, 2) Error: type mismatch: got <testing> but expected 'foo = object'
It looks to me that given the ambiguous identifier foo, nim prioritizes the type over the proc.
This is unexpected behavior. Usually, if you have a naming conflict between two modules (for example, two procs or two types named the same thing), you get the following error message:
c.nim(3, 9) Error: ambiguous identifier: 'foo' --use a.foo or b.foo
And of course, if you try defining a type and a proc with the same name in a single module, you get another error.
closes#1969, closes#7547, closes#7737, closes#11838, closes#12283,
closes#12714, closes#12720, closes#14053, closes#16118, closes#19670, closes#22645
I was going to wait on these but regression tests even for recent PRs
are turning out to be important in wide reaching PRs like #24010.
The other issues with the working label felt either finnicky (#7385,
#9156, #12732, #15247), excessive to test (#12405, #12424, #17527), or I
just don't know what fixed them/what the issue was (#16128: the PR link
gives a server error by Github, #12457, #12487).
It looks to me that given the ambiguous identifier foo, nim prioritizes the type over the proc.
The opposite is true in case of calls, in this case the foo in x.foo is treated like a regular expression which makes a symchoice since #23123 and overload resolution on symchoices only considers routines (this also happens in normal calls if type symbols are ambiguous). But this isn't mentioned in the spec, this should be done if a test is added for this, or maybe reconsidered.
a.nim
b.nim
c.nim
If you then compile c, this results in an error like:
It looks to me that given the ambiguous identifier
foo
, nim prioritizes the type over the proc.This is unexpected behavior. Usually, if you have a naming conflict between two modules (for example, two procs or two types named the same thing), you get the following error message:
And of course, if you try defining a type and a proc with the same name in a single module, you get another error.
So for consistency's sake, it seems like Nim should error if there's a naming conflict between a type and a proc in two different modules.
EDIT: It's worth mentioning that you don't really encounter this issue if you follow NEP1. Still, not everything does.
The text was updated successfully, but these errors were encountered: