2856 – static opIndex does not compile for a templated struct/class

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2856 - static opIndex does not compile for a templated struct/class
Summary: static opIndex does not compile for a templated struct/class
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords: patch, rejects-valid
Depends on:
Blocks:
Reported: 2009年04月18日 23:43 UTC by Rob Jacques
Modified: 2015年06月09日 01:18 UTC (History)
1 user (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Rob Jacques 2009年04月18日 23:43:28 UTC
Static opIndex functions result in compile time errors for templated structs and classes. Using a typedef, fixes the issue. static opCall and generic static functions don't appear to be affected.
Test case:
import std.stdio;
struct foo { static void opIndex(int i) { writefln("foo"); } }
struct bar(T) { static void opIndex(int i) { writefln("bar"); } }
int main(char[][] args) {
 foo[1];
 //bar!(float)[1]; // Error (# = __LINE__)
 typedef bar!(float) B; 
 B[1]; // Okay
 return 0;
}
main.d:#: Error: struct bar must be an array or pointer type, not void
main.d:#: Error: [i] has no effect in expression (struct bar[1])
Comment 1 Kenji Hara 2011年10月15日 04:07:40 UTC
https://github.com/D-Programming-Language/dmd/pull/453 


AltStyle によって変換されたページ (->オリジナル) /