Bug 7640 – CTFE: Confusing error message when looking up missing hash key

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-03-03T18:23:00Z
Last change time
2013-11-26T20:41:17Z
Keywords
CTFE, diagnostic
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2012-03-03T18:23:47Z
enum Enums { a, b } void main() { enum Fields = [ Enums.a : "a", ]; mixin("auto x = " ~ Fields[Enums.b] ~ ";"); } Errors: test.d(16): Error: argument to mixin must be a string, not ("auto x = " ~ [cast(Enums)0:"a"][cast(Enums)1] ~ ";") test.d(16): Error: argument to mixin must be a string, not ("auto x = " ~ [cast(Enums)0:"a"][cast(Enums)1] ~ ";") I'd rather the errors be something like: test.d(16): Error: CTFE: Key 'Enums.b' is not in 'Fields' test.d(16): Error: argument to mixin must be a string, not ("auto x = " ~ (__error) ~ ";") We could also get rid of duplicate error messages.
Comment #1 by yebblies — 2013-11-26T20:41:17Z
DMD v2.065 DEBUG testx.d(14): Error: key cast(Enums)1 not found in associative array [cast(Enums)0:"a"]