-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[C++20] [Modules] Confusing error message about invisible namespace #73893
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
Comments
@llvm/issue-subscribers-clang-modules Author: Chuanqi Xu (ChuanqiXu9)
I got this issue report in a private chat and I think it is better to track it.
The reproducer:
then when we compile
The issue reporter's opinion is that, the header The reason for the issue is that, in the diagnostic handler, we don't handle namespace decl specially. So that we will show the first declaration and say it is invisible to imply the users to export that. But it is confusing for namespace decl since it smells not good for users to export a whole namespace. Also, once a declaration in the namespace got exported, the namespace become visible too. So the solution in my mind may be, we can simply don't diagnose anything if the declaration is a namespace declaration. Then the showed error message will be:
|
I've been meaning to report this (or maybe something like this?) as well, but I hadn't come up with a good solution. I'm regularly told to import the wrong module -- "Oh, you tried to use foo::bar? I know about a module that contains namespace foo, you should import that!" If you need a reproducer for that (since I'm not sure if it's exactly the same as this), I can make one the next time I encounter it. |
How do you think the proposed solution? "To not diagnose on the namespace". Then for the your example, the message becomes to "bar is invisible" or "unknown identifier bar" or similar messages. Personally I feel such message are helpful enough.
I guess they'll be the same issue. But more reproducer can increase our confidence. |
Your solution sounds great |
I got this issue report in a private chat and I think it is better to track it.
The reproducer:
then when we compile
tc.cpp
, we'll see the error message like:The issue reporter's opinion is that, the header
vector
in the error message is confusing since there is nothing about<vector>
.The reason for the issue is that, in the diagnostic handler, we don't handle namespace decl specially. So that we will show the first declaration and say it is invisible to imply the users to export that. But it is confusing for namespace decl since it smells not good for users to export a whole namespace.
Also, once a declaration in the namespace got exported, the namespace become visible too. So the solution in my mind may be, we can simply don't diagnose anything if the declaration is a namespace declaration. Then the showed error message will be:
The text was updated successfully, but these errors were encountered: