https://issues.dlang.org/show_bug.cgi?id=12757
Issue ID: 12757
Summary: Refused fixed size array literal function argument
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Keywords: rejects-valid
Severity: normal
Priority: P1
Component: DMD
Assignee: [email protected]
Reporter: [email protected]
void foo(int[2] data) {}
void main() {
int[2] aux = [0: 10, 1: 20]; // OK
foo(aux); // OK
foo([0: 10, 1: 20]); // Error.
}
dmd 2.066alpha gives:
temp.d(5,8): Error: function temp2.foo (int[2] data) is not callable using
argument types (int[int])
A very similar but more specific and more useful example:
import std.traits: EnumMembers;
enum Foo : ubyte { A, B }
void bar(int[EnumMembers!Foo.length] input) {}
void main() {
immutable int[EnumMembers!Foo.length] input = [Foo.A: 10, Foo.B: 20];
bar(input); // OK.
bar([Foo.A: 10, Foo.B: 20]); // Error.
}
See also:
https://issues.dlang.org/show_bug.cgi?id=4703
--