www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7640] New: CTFE: Confusing error message when looking up missing hash key

http://d.puremagic.com/issues/show_bug.cgi?id=7640

           Summary: CTFE: Confusing error message when looking up missing
                    hash key
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com



18:23:47 PST ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 03 2012