Test cases: struct A { int[0] b; } A a = A(0); // Fails, compiler aborts A b = {b:0}; // OK, but perhaps shouldn't be. A c = A([]); // OK A d = {b:[]}; // OK Although the compiler shouldn't issue an assert, a zero length array should be enforced to have a 0 length initializer. Regards
This needs to be an error, because that 0 value has nowhere to be stored into: struct A { int[0] b; } A b = {b : 0};
Created attachment 813 [details] PATCH against rev 755: fix crash in first case Fixed: A a = A(0); // Fails, compiler aborts by issuing error msg. I'll dig a bit more into fixing the second case, that should be an error as way.
Just under the "duplicate union" error is where to look iirc.
Created attachment 844 [details] Patch for 5090 Reassigned to Walter. Attaching patch that turns assert into an error, but enforces that this corner case only happens for zero-length'd static arrays. Make any improvements you may wish to add/remove, as I generally suck at coming up with good, concise error messages. :~)
Just to make note, these forms of initialisation are still OK for zero-length static arrays: struct A { int[0] b; } A a = A(); // OK A b = {}; // OK A c = A([]); // OK A d = {b:[]}; // OK Regards
http://www.dsource.org/projects/dmd/changeset/823
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル