-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Use qualified name-lookup in module. #2324
Conversation
Allow lookup of non-exported names from local classes in function templates.
@@ -2169,6 +2169,7 @@ FMT_CONSTEXPR FMT_INLINE auto parse_arg_id(const Char* begin, const Char* end, | |||
template <typename Char, typename Handler> | |||
FMT_CONSTEXPR auto parse_width(const Char* begin, const Char* end, | |||
Handler&& handler) -> const Char* { | |||
using detail::auto_id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be unnecessary because we are in the detail namespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My first impulse as well.
This is similar to #2260 and the outcome the same: the name-lookup of detail::auto_id
fails with "auto_id
is not a member of detail
".
For more on that see below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest moving namespace qualification to the only place where auto_id
is used below.
The visibility of non-exported names used in (not only) function templates, and the lack of it during implicit template instantiation either directly or indirectly triggered by a call from importers of the module is a common theme. The situation in #2260 is simple. Here in #2324 it's more difficult because in this case there's a dependent local class involved which uses a non-exported name The million dollar question is: when is this name looked up and bound?
There are even worse examples present in the code (format.h:2640):
has a dependent local class that requires 12 entities from And there is I need to make a deep dive into the standard to figure out what's going on here and if this is the indended outcome. From my conversation with Cameron I get the impression that the observed behaviour is correct according to Microsoft's reading of the standard. Unfortunately I cannot cross-check with f.e. gcc (even though the modules branch is mostly there). May be I need to discuss this further or even bring this to SG2 or Core. |
Thanks for the detailed explanation. So what are the observable effects of not doing the namespace qualification of |
The non-
I ran a quick check with an alternative solution: by pulling all of these local dependent classes out of the function body into class templates at namespace scope, then none of the using declarations are required and everything works. This applies to
In the latter case this saves 12 seemingly unnecessary using declarations. And almost all non- For example: pull class
I can modify the PR with this alternative approach. |
No need to, some of these will become lambdas in the future so adding qualification is better. |
@@ -2198,6 +2199,7 @@ FMT_CONSTEXPR auto parse_width(const Char* begin, const Char* end, | |||
template <typename Char, typename Handler> | |||
FMT_CONSTEXPR auto parse_precision(const Char* begin, const Char* end, | |||
Handler&& handler) -> const Char* { | |||
using detail::auto_id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
Namespace qualification doesn't help, that's the crux of the matter: at the point of name-lookup of At present, there are two options available:
|
Not a fan of this module "feature", hopefully they'll fix it somehow. |
Me too! I will discuss this with people more in the know as I said before. I really want Cameron's opinion on that, and hopefully Gaby's too. Let's see if I can make them interested into this discussion here. |
Thank you! |
And allow lookup of non-exported names from local classes in function templates.
Using declarations link these names into the body and make them available for name-lookup when the local classes are instantiated together with the function bodies that contain them.