Bug 17571 – Cannot create alias of __traits(getMember, ...)

Status
RESOLVED
Resolution
DUPLICATE
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-06-29T05:28:54Z
Last change time
2018-03-13T07:28:11Z
Assigned to
No Owner
Creator
Shachar Shemesh

Comments

Comment #0 by shachar — 2017-06-29T05:28:54Z
Consider the following program: import unistd = core.sys.posix.unistd; alias func = __traits(getMember, unistd, "write"); When trying to compile: test.d(3): Error: basic type expected, not __traits test.d(3): Error: semicolon expected to close alias declaration test.d(3): Error: declaration expected, not '__traits' Since unistd.write is a function, there is no reason for me not to be able to create an alias of it. The only reason I'm marking this as a minor issue is because there is a workaround: import unistd = core.sys.posix.unistd; import std.meta; alias func = Alias!(__traits(getMember, unistd, "write")); This, however, goes outside the definition of what std.meta.Alias was meant for. It was meant for aliasing non-aliasable objects, not for aliasing functions (which is what is happening in this case).
Comment #1 by dlang-bugzilla — 2017-06-29T12:52:00Z
Comment #2 by shachar — 2017-06-29T13:17:50Z
(In reply to Vladimir Panteleev from comment #1) > It is a syntax issue. See: > https://blog.thecybershadow.net/2015/04/28/the-amazing-template-that-does- > nothing/ I'm sorry, I don't understand. Are you saying that because it is a syntax issue it is not a bug? Shachar
Comment #3 by dlang-bugzilla — 2017-06-29T16:18:29Z
It is a limitation of the current grammar. It's probably fixable by changing the grammar, which I think would make sense.
Comment #4 by simen.kjaras — 2018-03-13T07:28:11Z
*** This issue has been marked as a duplicate of issue 7804 ***