[Issue 10597] New: opDollar not callable in static constext
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jul 10 08:49:47 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10597
Summary: opDollar not callable in static constext
Product: D
Version: D1 & D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: monarchdodra at gmail.com
--- Comment #0 from monarchdodra at gmail.com 2013-07-10 08:49:46 PDT ---
Discussed here:
http://forum.dlang.org/thread/ddktjwsavfeiahblvrit@forum.dlang.org
//----
struct R
{
void opIndex(int);
int opDollar();
}
R r;
void foo()
{
static assert(is(typeof(r[0]))); //ok
static assert(is(typeof(r[$]))); //ok
}
static assert(is(typeof(r[0]))); //ok
static assert(is(typeof(r[$]))); //fails (!)
struct S
{
void foo()
{
static assert(is(typeof(r[0]))); //ok
static assert(is(typeof(r[$]))); //ok
}
static assert(is(typeof(r[0]))); //ok
static assert(is(typeof(r[$]))); //fails (!)
}
//----
Calling opDollar in a "static context" fails. Apparently, it would appear that
opDollar is looking for some sort of "this" or context pointer.
If opDollar is defined as static, or enum, then the above code works.
The error message is kind of weird too:
main.d(15): Error: static assert (is(typeof(r.opIndex((int __dollar =
r.opDollar();
, __dollar))))) is false
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list