6123 – [CTFE] Cannot call a template member method inside delegate/function literal with -inline.

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6123 - [CTFE] Cannot call a template member method inside delegate/function literal with -inline.
Summary: [CTFE] Cannot call a template member method inside delegate/function literal ...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Mac OS X
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
Reported: 2011年06月08日 00:47 UTC by kennytm
Modified: 2011年06月11日 06:42 UTC (History)
1 user (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
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 によって変換されたページ (->オリジナル) /