Bug 18974 – ICE with mixin templates, inheritance and overloading

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-06-12T15:23:00Z
Last change time
2020-03-21T03:56:41Z
Keywords
ice
Assigned to
No Owner
Creator
Mathias LANG

Comments

Comment #0 by pro.mathias.lang — 2018-06-12T15:23:00Z
This kills DMD: ``` class Expression {} class Statement : Expression {} private template AssertFalse (T, Ret) { Ret visit (const T node) { assert(0, T.stringof); } } class AssertSemanticVisitor (Node) { mixin AssertFalse!(Statement, void) A; mixin AssertFalse!(Expression, void) B; } class ExpressionVisitor : AssertSemanticVisitor!(void) { public override void visit (Expression) { assert(0); } } ``` A debug build shows: ``` --- ERROR: This is a compiler bug. Please report it via https://issues.dlang.org/enter_bug.cgi with, preferably, a reduced, reproducible example and the information below. DustMite (https://github.com/CyberShadow/DustMite/wiki) can help with the reduction. --- DMD v2.080.1-317-gda13edb77 predefs DigitalMars Posix linux ELFv1 LittleEndian D_Version2 all D_SIMD D_InlineAsm_X86_64 X86_64 CRuntime_Glibc D_LP64 D_PIC assert D_HardFloatbinary ../dmd/generated/linux/release/64/dmd version v2.080.1-317-gda13edb77 config ../dmd/generated/linux/release/64/dmd.conf DFLAGS -I../dmd/generated/linux/release/64/../../../../../druntime/import -I../dmd/generated/linux/release/64/../../../../../phobos -L-L../dmd/generated/linux/release/64/../../../../../phobos/generated/linux/release/64 -L--export-dynamic -fPIC --- core.exception.AssertError@dmd/dsymbolsem.d(3453): Assertion failure ---------------- ??:? _d_assertp [0xe754a7c9] ??:? _ZN22DsymbolSemanticVisitor23funcDeclarationSemanticEP15FuncDeclaration [0xe7371bde] ??:? _ZN22DsymbolSemanticVisitor5visitEP15FuncDeclaration [0xe73722e0] ??:? _ZN15FuncDeclaration6acceptEP7Visitor [0xe73c513d] ??:? _Z15dsymbolSemanticP7DsymbolP5Scope [0xe736868c] ??:? _ZN22DsymbolSemanticVisitor14attribSemanticEP17AttribDeclaration [0xe736c3e6] ??:? _ZN22DsymbolSemanticVisitor5visitEP17AttribDeclaration [0xe736c448] ??:? _ZN16ParseTimeVisitorI10ASTCodegenE5visitEP15ProtDeclaration [0xe7448d82] ??:? _ZN15ProtDeclaration6acceptEP7Visitor [0xe730b095] ??:? _Z15dsymbolSemanticP7DsymbolP5Scope [0xe736868c] ??:? _ZN22DsymbolSemanticVisitor5visitEP16ClassDeclaration [0xe7375e4c] ??:? _ZN16ClassDeclaration6acceptEP7Visitor [0xe7335e95] ??:? _Z15dsymbolSemanticP7DsymbolP5Scope [0xe736868c] ??:? _ZN22DsymbolSemanticVisitor5visitEP6Module [0xe736d779] ??:? _ZN6Module6acceptEP7Visitor [0xe7357e09] ??:? _Z15dsymbolSemanticP7DsymbolP5Scope [0xe736868c] ??:? int dmd.mars.tryMain(ulong, const(char)**) [0xe73fc19b] ??:? _Dmain [0xe73fd582] ```
Comment #1 by simen.kjaras — 2018-06-13T07:43:51Z
Further simplified: template Mixin() { void fun(const int) { } } class Foo { mixin Mixin!(); mixin Mixin!(); } class Bar : Foo { override void fun(int) { } // Line 11 } This gives a slightly different stack trace (top calls are still the same). This difference is caused by templatization of Foo, and can be disregarded. Changing the type on line 14 from A to const(A) removes the crash. Rewriting to using a single invocation of Mixin with two function definitions inside gives this message: Error: function void foo.Bar.fun(A) does not override any function, did you mean to override void foo.Foo!int.Foo.Mixin!(A, B).fun(const(A))?