D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.

Issue 6123

Summary: [CTFE] Cannot call a template member method inside delegate/function literal with -inline.
Product: D Reporter: kennytm
Component: dmdAssignee: No Owner <nobody>
Status: RESOLVED FIXED
Severity: normal CC: clugdbug
Priority: P2 Keywords: rejects-valid
Version: D2
Hardware: Other
OS: Mac OS X

Description kennytm 2011年06月08日 00:47:55 UTC
Test case:
-------------------------
struct Bug6123(T) {
 void f() {}
 // can also trigger if the struct is normal but f is template
}
static assert({
 auto piece = Bug6123!int(); 
 piece.f();
 return true;
}());
-------------------------
Error: Cannot interpret &this at compile time
x.d(8): Error: cannot evaluate delegate bool()
{
Bug6123!(int) piece = Bug6123();
ref Bug6123!(int) this = piece;
 , assert(&this,"null this");
return true;
}
() at compile time
x.d(4): Error: static assert (delegate bool()
{
Bug6123!(int) piece = Bug6123();
ref Bug6123!(int) this = piece;
 , assert(&this,"null this");
return true;
}
()) is not evaluatable at compile time
-------------------------
(Why that 'assert' is generated in CTFE anyway?)

AltStyle によって変換されたページ (->オリジナル) /