Bug 17625 – Confusing error message for private functions in different modules

Status
RESOLVED
Resolution
FIXED
Severity
trivial
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-07-09T05:05:15Z
Last change time
2018-01-29T15:21:58Z
Keywords
diagnostic
Assigned to
No Owner
Creator
Ketmar Dark

Comments

Comment #0 by ketmar — 2017-07-09T05:05:15Z
i don't know how to make a clear summary for this, sorry. anyway, here is the code. let's create three modules: === z00.d === module z00; private int boo () { return 42; } === z01.d === module z01; private int boo () { return 69; } === zmain.d === module zmain; import z00, z01; void main () { boo(); } now, do: dmd -c -o- zmain.d z00.d z01.d and you'll get: zmain.d(3): Error: z01.boo at z01.d(2) conflicts with z00.boo at z00.d(2) zmain.d(3): Error: function z01.boo is not accessible from module zmain while the second error message gives at least *some* information, the first one is not only completely useless, but is misleading too: user may think that he has to rename one of the private functions to get rid of it. i think that compiler should just say "undefined identifier `boo`", 'cause visibility rules mandates that private functions are not visible at that point, and there is no sense in trying to resolve anything there.
Comment #1 by dlang-bugzilla — 2017-07-10T21:14:46Z
I also get another line from the compiler, before the two shown: zmain.d(3): Deprecation: zmain.boo is not visible from module zmain This adds to the confusion because there is no "boo" in zmain (the compiler is referring to the overload set created by the imports). But it also points that it is related to 313/314, so when the deprecation period of those expires, the error messages may change.
Comment #2 by razvan.nitu1305 — 2018-01-26T13:42:52Z
Comment #3 by github-bugzilla — 2018-01-29T15:21:58Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/71c462f5f8688bdfe398e14c4c3f576ce40f8ef2 Fix Issue 17625 - Confusing error message for private functions in different modules https://github.com/dlang/dmd/commit/e0327f382fb339b7054d96781c7f4528d3bf35bf Merge pull request #7785 from RazvanN7/Issue_17625 Fix Issue 17625 - Confusing error message for private functions in different modules