6280 – [CTFE] Cannot put 'in' expression of AA in an 'if' condition

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6280 - [CTFE] Cannot put 'in' expression of AA in an 'if' condition
Summary: [CTFE] Cannot put 'in' expression of AA in an 'if' condition
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other All
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
Reported: 2011年07月10日 04:16 UTC by kennytm
Modified: 2011年07月26日 15:18 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年07月10日 04:16:22 UTC
Test case:
--------------------------------
static assert({
 if (0 in [0:0]) {}
 return true;
}());
--------------------------------
x.d(4): Error: cannot evaluate delegate pure nothrow bool()
{
if (0 in [0:0])
{
}
return true;
}
() at compile time
x.d(1): Error: static assert (delegate pure nothrow bool()
{
if (0 in [0:0])
{
}
return true;
}
()) is not evaluatable at compile time
--------------------------------
Calling 'if((a in b) !is null)' can workaround the problem.
Comment 1 kennytm 2011年07月10日 06:00:06 UTC
The problem is there isn't an IndexExp::isBool.


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