01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
2010-01-19 Tue
■ 要素が構造体の連想配列が作れない? [D言語]
javascript 見たいな、
opDispatch と Variant を使った、
任意の名前の任意の値を格納できるクラスを作ろうとした。
で、 Variant を要素に持つ連想配列を作って、
dmd 2.039 でコンパイルしたら dmd がこけた。
import std.stdio;
import std.variant;
void main()
{
Variant[string] va;
writeln(va.length); //Assertion failure: 'impl' on line 3882 in file 'mtype.c'
}
ただの構造体でもやってみたら、
要素が構造体の連想配列が作れた。
import std.stdio;
struct S{}
void main()
{
S[string] sa;
writeln(sa.length); //OK
}
import std.variant を追加してみる。
import std.stdio;
import std.variant;
struct S{}
void main()
{
S[string] sa;
writeln(sa.length); //Assertion failure: 'impl' on line 3882 in file 'mtype.c'
}
えー
std.variant をインポートすると、要素が構造体の連想配列が作れない?
import std.variant assoc array Issue で検索
これっぽい?
digitalmars.D - Variant[string] associative array ... fail?`
Issue 2451 - Adding structs that use opAssign or postblit to an AA is broken
2010-10-20 追記
std.variantをimportするだけでコンパイルエラー - はてなかよっ!
Issue 3552 - ICE(mtype.c): declaring a variable called 'AssociativeArray' then using an AA.
なるほど、 AssociativeArray って名前がだめなのか
import std.stdio;
struct S{}
void main()
{
int AssociativeArray;
S[string] sa;
writeln(sa.length); //Assertion failure: 'impl' on line 3882 in file 'mtype.c'
}