[Issue 4063] New: [CTFE] key not found in AA gives bad error message

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Apr 5 05:29:46 PDT 2010


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

           Summary: [CTFE] key not found in AA gives bad error message
           Product: D
           Version: future
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2010-04-05 05:29:45 PDT ---
int foo(string s) {
    enum int[string] aa = ["aa":1, "bb":2];
    return aa[s];
}
enum _ = foo("xx"); // line 5
void main() {}


dmd 2.042 gives:

test.d(5): Error: cannot evaluate foo("xx") at compile time
test.d(5): Error: cannot evaluate foo("xx") at compile time


A much better pair of error messages can be:

test.d(3): Error: Range violation. Key "xx" not found in associative array
'aa'.
test.d(5): Error: cannot evaluate foo("xx") at compile time.


Or just (if the symmetry with the run-time error is not considered important):

test.d(3): key "xx" not found in associative array 'aa'.
test.d(5): Error: cannot evaluate foo("xx") at compile time.

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


More information about the Digitalmars-d-bugs mailing list