From 3f9f13594c2e41b06199c46ea7f431710c98959b Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 27 Sep 2012 23:50:52 +0200 Subject: [PATCH] Work around unmerged types being returned from frontend. Fixes DMD testcase 'funclit'. --- gen/tocall.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/gen/tocall.cpp b/gen/tocall.cpp index 5b6b4696..6d6ff765 100644 --- a/gen/tocall.cpp +++ b/gen/tocall.cpp @@ -25,7 +25,20 @@ TypeFunction* DtoTypeFunction(DValue* fnval) } else if (type->ty == Tdelegate) { - Type* next = type->nextOf(); + // FIXME: There is really no reason why the function type should be + // unmerged at this stage, but the frontend still seems to produce such + // cases; for example for the uint(uint) next type of the return type of + // (&zero)(), leading to a crash in DtoCallFunction: + // --- + // void test8198() { + // uint delegate(uint) zero() { return null; } + // auto a = (&zero)()(0); + // } + // --- + // Calling merge() here works around the symptoms, but does not fix the + // root cause. + + Type* next = type->nextOf()->merge(); assert(next->ty == Tfunction); return static_cast(next); }