-
-
Notifications
You must be signed in to change notification settings - Fork 609
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
Fix issue 21340 - extern(C++,(emptyTuple)) should result in no namespace not an error #11905
Conversation
|
Thanks for your pull request and interest in making D better, @thewilsonator! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#11905" |
|
This is principally to allow without having to duplicate the definition. |
src/dmd/traits.d
Outdated
| @@ -1973,7 +1974,14 @@ Expression semanticTraits(TraitsExp e, Scope* sc) | |||
| for (auto ns = p.cppnamespace; ns !is null; ns = ns.cppnamespace) | |||
| { | |||
| ns.dsymbolSemantic(sc); | |||
| exps.insert(0, ns.exp); | |||
| auto se = ns.exp.toStringExp(); | |||
| const sident = se.toStringz(); | |||
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'm not sure why toString() doesn't work here
8ce0ccb to
1956414
Compare
|
What does the spec have to say about this? We were talking in the beerconf yesterday about the divergence of the compiler from the spec. |
|
Not sure if this makes much sense to me. When I first looked at |
|
@WalterBright Not much it is thoroughly under-specced : there is the grammar and https://dlang.org/spec/cpp_interface.html#cpp-namespaces |
|
Having the ability to write |
1956414 to
e9662b2
Compare
|
|
ad45f2f to
f8d6993
Compare
|
By the time we get to semantic there is no difference between the tuple and nested namespaces anyway. |
|
@ibuclaw anonymous namespaces are private symbols anyway, I don't see a point in exposing the ability to interact with them . OTOH this solves a real issue. |
That is to say |
|
But why do we need to support |
|
and because |
template ScopeClass(C)
if (is(C == class) && __traits(getLinkage, C) == "C++")
{
static if (__traits(getCppNamespaces,C).length)
alias _namespaces_ = __traits(getCppNamespaces,C)[0];
else
alias _namespaces_ = AliasSeq!();
extern(C++, class)
extern(C++, _namespaces_)
struct ScopeClass { ... }
}What's wrong with this ? |
Yes, and that is precisely the reason why allowing |
|
I mean I'm all for deprecating them, but that requires convincing Walter and waiting out the deprecation period. |
Use an extra set of parenthesis for disambiguation. |
back to square one |
|
It just means you need to ensure it gets parsed as an empty tuple |
f8d6993 to
9fa10e3
Compare
9fa10e3 to
882a72a
Compare
|
Done. |
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.
Where did the parser changes go ? This doesn't seem to fix the issue. The trailing comma change was good, and the test for empty tuple with parentheses should be there too.
882a72a to
0c699ab
Compare
Sorry I misinterpreted #11905 (comment) to mean just the empty tuple.
Done. |
0c699ab to
3aa48c3
Compare
d39eaf1 to
88e676d
Compare
| if (ns.exp.isErrorExp()) | ||
| return ErrorExp.get(); | ||
|
|
||
| auto se = ns.exp.toStringExp(); |
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.
Is it possible for this to return null?
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.
its has gone through semantic at this point so I don't think so.
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.
Need a spec PR explaining just what the semantics of this are. Need a rationale as to why, too. "should result in no namespace and not an error" isn't sufficient. What actual programming problem does this solve?
|
|
@Geod24 ping |
|
Yep, will give another round of review sound. TBH implementation seems a bit too tailored, but feature is 👍 |
88e676d to
e3713c5
Compare
|
Why does circle keep failing (randomly?)? |
spec PR done, rationale given
e3713c5 to
23fddd8
Compare
23fddd8 to
17845af
Compare
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.
LGTM. Sorry for the delay, the fresh eyes did help :D
|
Thanks! |
…)) should result in no namespace not an error