void foo() {} void main() { [foo]; } Dmd 2.047 prints: Internal error: ..\ztc\cod1.c 2650
Changing platform to All (affects Linux too). Similar code: void[] p = [cast(void)42]; As of DMD-2.051, now prints: Internal error: ../ztc/cod1.c 3057
diff --git a/src/expression.c b/src/expression.c index 9d116b9..1bd9e42 100644 --- a/src/expression.c +++ b/src/expression.c @@ -3200,6 +3200,10 @@ Expression *ArrayLiteralExp::semantic(Scope *sc) type = t0->arrayOf(); //type = new TypeSArray(t0, new IntegerExp(elements->dim)); type = type->semantic(loc, sc); + + if (type->nextOf()->ty == Tvoid) + error("array literal of type void[] has no value"); + return this; }
Maybe if (type->nextOf()->ty == Tvoid) error("%s of type void[] has no value", toChars()); Is a better error message (I really am no good at writing them :)
Oops, previous patch didn't take into account that empty '[]' array literals are allowed to be void. diff --git a/src/expression.c b/src/expression.c index 9d116b9..1e68ce7 100644 --- a/src/expression.c +++ b/src/expression.c @@ -3197,6 +3197,9 @@ Expression *ArrayLiteralExp::semantic(Scope *sc) Type *t0; elements = arrayExpressionToCommonType(sc, elements, &t0); + if (elements->dim > 0 && t0->ty == Tvoid) + error("array literal %s has no value", toChars()); + type = t0->arrayOf(); //type = new TypeSArray(t0, new IntegerExp(elements->dim)); type = type->semantic(loc, sc);
*** Issue 5929 has been marked as a duplicate of this issue. ***
https://github.com/D-Programming-Language/dmd/commit/dbdbeb1ed9890e317c0fbb594dd331f18d025864 https://github.com/D-Programming-Language/dmd/commit/d7096004298cdbffa4f4889be47d8f6ee627fdfc
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル