4065 – [CTFE] AA "in" operator doesn't work

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4065 - [CTFE] AA "in" operator doesn't work
Summary: [CTFE] AA "in" operator doesn't work
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 major
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
Reported: 2010年04月05日 05:41 UTC by bearophile_hugs
Modified: 2015年06月09日 05:11 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 bearophile_hugs 2010年04月05日 05:41:16 UTC
bool foo(string s) {
 enum int[string] aa = ["aa":1, "bb":2];
 return cast(bool)(s in aa);
}
enum bool r = foo("xx");
void main() {}
dmd 2.042 gives:
test.d(3): Error: Cannot interpret s in (["aa":1,"bb":2]) at compile time
test.d(5): Error: cannot evaluate foo("xx") at compile time
test.d(5): Error: cannot evaluate foo("xx") at compile time
I have tagged this as major bug because it limits a lot the uses of AAs in CTFE. And AA.get too is not available yet at compile-time.
I presume this is caused by the pointers that are not available yet at compile-time.


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