From e5d5a0e5e6573f8961e443ec7f725e9a00a94cb0 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Wed, 5 Nov 2008 06:41:22 +0000 Subject: [PATCH] Disallow x[y] if x has a maybe type --- dmd2/expression.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dmd2/expression.c b/dmd2/expression.c index 922d340..dc5de9e 100644 --- a/dmd2/expression.c +++ b/dmd2/expression.c @@ -7225,6 +7225,9 @@ Expression *IndexExp::semantic(Scope *sc) assert(e1->type); // semantic() should already be run on it e = this; + if (e1->type->ty == Tmaybe) + error("Attempt to index %s of type %s, which may be null", e1->toChars(), e1->type->toChars()); + // Note that unlike C we do not implement the int[ptr] t1 = e1->type->toBasetype(); -- 2.11.4.GIT