http://d.puremagic.com/issues/show_bug.cgi?id=8892
--- Comment #6 from Kenji Hara <[email protected]> 2013-01-27 01:16:38 PST --- (In reply to comment #4) > What I don't understand is why the above fails at compile-time but the > following compiles (it fails at runtime): > > char[2] data = ['A']; > > $ object.Error: lengths don't match for array copy, 2 = 1 > > I think this case should also an accepts-invalid, because the compiler can see > at compile-time that the lengths don't match. It is known inconsistency around static array initialization. int[3] garr = [1,2]; // When creating data section, garr[2] is filled by 0 void main() { int[3] larr = [1,2]; // This is translated to runtime element-wise blit assign: // larr[0..3] = [1,2] // and fails at runtime. } When we based on the issue, following code still have similar issue. struct Foo { char[2] data; } void main() { auto f = Foo(['A']); // 1. should be compile time error, array length mismatch, or // 2. the initializer should be translated to Foo(['A', char.init]) ? } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
