From d2e267008f47c7bafe7c66dbb316e6b9568c70ab Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Tue, 2 Jan 2018 18:24:07 -0800 Subject: [PATCH] fix Issue 16621 - [REG2.060] DMD hang in semantic3 on alias this --- src/dmd/mtype.d | 7 ++++++- test/compilable/test16621.d | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 test/compilable/test16621.d diff --git a/src/dmd/mtype.d b/src/dmd/mtype.d index d97baf45625d..ead327f90382 100644 --- a/src/dmd/mtype.d +++ b/src/dmd/mtype.d @@ -6,6 +6,8 @@ * Authors: $(LINK2 http://www.digitalmars.com, Walter Bright) * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/mtype.d, _mtype.d) + * Documentation: https://dlang.org/phobos/dmd_mtype.html + * Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/mtype.d */ module dmd.mtype; @@ -6057,9 +6059,12 @@ extern (C++) final class TypeFunction : TypeNext */ while (1) { - Type tat = ta.toBasetype().aliasthisOf(); + Type tab = ta.toBasetype(); + Type tat = tab.aliasthisOf(); if (!tat || !tat.implicitConvTo(tprm)) break; + if (tat == tab) + break; ta = tat; } diff --git a/test/compilable/test16621.d b/test/compilable/test16621.d new file mode 100644 index 000000000000..d5800b12401c --- /dev/null +++ b/test/compilable/test16621.d @@ -0,0 +1,23 @@ +// https://issues.dlang.org/show_bug.cgi?id=16621 + +template xxx() +{ + Vector2f xxx() + { + return this; + } +} + +struct Vector2f +{ + mixin xxx!(); + alias xxx this; +} + +void foo(ref Vector2f pos); + +void test() +{ + Vector2f v; + foo(v); +}