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

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2010-04-05T05:41:00Z
Last change time
2015-06-09T05:11:51Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2010-04-05T05:41:16Z
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.
Comment #1 by clugdbug — 2011-06-17T01:09:17Z