Bug 13269 – Traits hasMember, getMember and compiles get buggy with opDispatch

Status
NEW
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2014-08-07T20:02:25Z
Last change time
2024-12-13T18:23:39Z
Assigned to
No Owner
Creator
Daniel Čejchan
Moved to GitHub: dmd#18864 →

Comments

Comment #0 by czdanol — 2014-08-07T20:02:25Z
Hey, this code returns true: class Test { void opDispatch( string s, Args ... )( auto ref Args args ) if( false ) { } } pragma( msg, __traits( hasMember, Test, "WHATEVEVER_DUDE" ) ); Also, stuff like traits compiles and getMember (but that only in compiles) behave the same.
Comment #1 by czdanol — 2014-08-07T20:04:47Z
Ah, and that Args ... has to be there, too. Just saying.
Comment #2 by default_357-line — 2020-02-12T09:09:49Z
Just ran into this. Seems to only happen if there's arguments, if you take out Args it correctly determines that opDispatch never matches.
Comment #3 by default_357-line — 2020-02-12T09:15:17Z
Workaround: it works if you use Test.init instead of Test
Comment #4 by default_357-line — 2020-02-12T09:22:21Z
Note: it's actually not possible rn with `hasMember` to check if a *type* has a member without also (brokenly) checking if an expression of the type has the member. The only option is `__traits(compiles, Type.member)`.
Comment #5 by robert.schadek — 2024-12-13T18:23:39Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18864 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB