Thread overview | |||||
---|---|---|---|---|---|
|
July 03, 2007 [Issue 1310] New: alias opCall vs struct literal | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=1310 Summary: alias opCall vs struct literal Product: D Version: 1.017 Platform: PC OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: lutger.blijdestijn@gmail.com When a struct has opCall through an alias, it is not recognized if the aliased symbol is a delegate (not as in a member function). Whether this construct is legal or not, the current behaviour is inconsistent. The following compiles without error but does not do what one expects. This applies to dmd 1.014-dmd 1.018 and probably the 2.x branch too. struct A { int delegate() foo; alias foo opCall; // not seen, see below } struct B { int foo() { return 0; } alias foo opCall; // ok } void main() { A a; B b; auto resultA = a(); pragma(msg, typeof(resultA).stringof); // prints 'A', struct initializer auto resultB = b(); pragma(msg, typeof(resultB).stringof); // prints 'int', recognizes opCall } -- |
July 23, 2007 [Issue 1310] alias opCall vs struct literal | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1310 thomas-dloop@kuehne.cn changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement OS/Version|Windows |All Platform|PC |All ------- Comment #1 from thomas-dloop@kuehne.cn 2007-07-23 14:55 ------- The same behaviour is caused by: # struct A { # int opCall; # } As far as I can see the code behaves as documented - opCall expects a function not a delegate or function pointer - however issuing at least a warning if -w is used would be sensible. Adding delegate/function pointer support for op* member functions might be interesting nevertheless. -- |
August 09, 2012 [Issue 1310] alias opCall vs struct literal | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1310 Denis Shelomovskij <verylonglogin.reg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |verylonglogin.reg@gmail.com --- Comment #2 from Denis Shelomovskij <verylonglogin.reg@gmail.com> 2012-08-09 13:30:40 MSD --- By the way, latest dmd v2.060 correctly (as documented) complains: --- Error: struct A does not overload () --- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation