http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=67928 He mentioned that static array can't be used as AA keys. So I tested with the newest DMD: void main() { char[char[3]] k; k["dfs"]='a'; } fails with msg: Internal error: ..\ztc\cod1.c 2529
*** Bug 2502 has been marked as a duplicate of this bug. ***
The original version for this bug report was 2.012, and in both D1 and D2, it used to ICE in cod1.c. (Test cases also ICEs in 1.020). It was fixed in DMD2.026, but not listed in the changelog and not fixed in D1. In recent versions of D1, it ICEs in e2ir.c. I've changed compiler version and title accordingly.
Actually in D2 it doesn't ICE, but it generates incorrect code, because of bug 2954. D2 needs this patch, as well as a fix to bug 2954. The ICE is because e2->elem() turns the string literal into a TYarray, instead of a TYsarray, so the length is lost. This patch restores it in the case where a fixed-length array is used. PATCH against DMD1.047. =================================================================== --- e2ir.c (revision 192) +++ e2ir.c (working copy) @@ -4020,10 +4020,15 @@ // n2 becomes the index, also known as the key n2 = e2->toElem(irs); - if (n2->Ety == TYstruct || n2->Ety == TYarray) + if (tybasic(n2->Ety) == TYstruct || tybasic(n2->Ety) == TYarray) { n2 = el_una(OPstrpar, TYstruct, n2); n2->Enumbytes = n2->E1->Enumbytes; + if (taa->index->ty==Tsarray) + { + assert(e2->type->size() == taa->index->size()); + n2->Enumbytes = taa->index->size(); + } //printf("numbytes = %d\n", n2->Enumbytes); assert(n2->Enumbytes); } ========= TEST CASE (still fails on D2): void main() { char[char[3]] ac; char[3] c = "abc"; ac["abc"]='a'; assert(ac[c]=='a'); char[dchar[3]] ad; dchar[3] d = "abc"d; ad["abc"d]='a'; assert(ad[d]=='a'); }
*** Issue 3357 has been marked as a duplicate of this issue. ***
The patch for bug 3357 should be applied at the same time, it's the other half of the same issue (the fix needs to be applied to opIn() as well as opIndex()).
Fixed dmd 1.049
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル