D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7640 - CTFE: Confusing error message when looking up missing hash key
Summary: CTFE: Confusing error message when looking up missing hash key
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: CTFE, diagnostic
Depends on:
Blocks:
 
Reported: 2012-03-03 18:23 UTC by Andrej Mitrovic
Modified: 2013-11-26 20:41 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrej Mitrovic 2012-03-03 18:23:47 UTC
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 yebblies 2013-11-26 20:41:17 UTC
DMD v2.065 DEBUG
testx.d(14): Error: key cast(Enums)1 not found in associative array [cast(Enums)0:"a"]