D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7434 - Error involving array literal created in ctfe gives wrong line number
Summary: Error involving array literal created in ctfe gives wrong line number
Status: RESOLVED DUPLICATE of issue 3812
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: Don
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2012-02-03 23:02 UTC by yebblies
Modified: 2015-06-09 05:10 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description yebblies 2012-02-03 23:02:53 UTC

    
Comment 1 yebblies 2012-02-03 23:03:18 UTC
int[string] initHash(in string[] words) {
        int[string] h;

        for (auto i=0; i < words.length; i++) {
                h[words[i]] = i; // Compiler points to this line and says:
//Error: non-constant expression ["abc":0,"def":1,"ghi":2]
        }

        return h;
}

int[string] hash3 = initHash(["abc", "def", "ghi"]);
Comment 2 yebblies 2012-02-03 23:18:54 UTC
I can't see how to do this, but I assume there's a clean way to trace back to the CallExp that's being interpreted and use that's Loc.
Comment 3 yebblies 2012-02-03 23:25:41 UTC
Actually never mind, this is the same thing as 3812, and the patch there fixes it.

*** This issue has been marked as a duplicate of issue 3812 ***