www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23151] New: ICE:

https://issues.dlang.org/show_bug.cgi?id=23151

          Issue ID: 23151
           Summary: ICE:
                    core.exception.AssertError src/dmd/aggregate.d(678):
                    Assertion failure
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: alphaglosined gmail.com

From:
https://forum.dlang.org/post/mailman.168.1654048512.31357.digitalmars-d puremagic.com

```d
interface I {
        void intfunc(int x);
}

auto makeBaseObj() {
        int realPrivateX;
        class Base : I {
                private int modulePrivateX;
                int publicX;
                override void intfunc(int x) {
                        realPrivateX++; // expected OK
                }
        }
        return new Base;
}

auto makeDerivedObj() {
        int realPrivateY;
        class Derived : typeof(makeBaseObj()) {
                private int modulePrivateY;
                int publicY;
                override void intfunc(int x) {
                        realPrivateX++; // expected NG
                        modulePrivateX++;
                }
        }
        return new Derived;
}
```

Output:

/tmp/test.d(20): Error: class `test.makeDerivedObj.Derived` is nested within
`makeDerivedObj`, but super class `Base` is nested within `makeBaseObj`
---
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.098.1-1176-g005d97cb4
predefs   DigitalMars LittleEndian D_Version2 all D_SIMD Posix ELFv1 linux
CRuntime_Glibc CppRuntime_Gcc D_InlineAsm_X86_64 X86_64 D_LP64 D_PIC assert
D_PreConditions D_PostConditions D_Invariants D_ModuleInfo D_Exceptions
D_TypeInfo D_HardFloat
binary    dmd
version   v2.098.1-1176-g005d97cb4
config    /usr/src/d/bin/dmd.conf
DFLAGS    -I/usr/src/d/druntime/import -I/usr/src/d/druntime/src
-I/usr/src/d/phobos -L-L/usr/src/d/phobos/generated/linux/release/32
-L-L/usr/src/d/phobos/generated/linux/release/64 -L--no-warn-search-mismatch
-L--export-dynamic -fPIC
---
core.exception.AssertError src/dmd/aggregate.d(678): Assertion failure
----------------
??:? _d_assertp [0x55672da66de1]
??:? void dmd.aggregate.AggregateDeclaration.makeNested() [0x55672d752f64]
??:? _ZN22DsymbolSemanticVisitor23funcDeclarationSemanticEP15FuncDeclaration
[0x55672d7e2c80]
??:? _ZN22DsymbolSemanticVisitor5visitEP15FuncDeclaration [0x55672d7e5d78]
??:? _ZN15FuncDeclaration6acceptEP7Visitor [0x55672d857f61]
??:? _Z15dsymbolSemanticP7DsymbolP5Scope [0x55672d7d9b09]
??:? void
dmd.dsymbolsem.DsymbolSemanticVisitor.visit(dmd.dclass.ClassDeclaration).__lambda9!(dmd.dsymbol.Dsymbol).__lambda9(dmd.dsymbol.Dsymbol)
[0x55672d7ea933]
??:? void
dmd.dsymbol.foreachDsymbol(dmd.root.array.Array!(dmd.dsymbol.Dsymbol).Array*,
void delegate(dmd.dsymbol.Dsymbol)) [0x55672d7d3293]
??:? _ZN22DsymbolSemanticVisitor5visitEP16ClassDeclaration [0x55672d7e9e04]
??:? _ZN16ClassDeclaration6acceptEP7Visitor [0x55672d794b85]
??:? _Z15dsymbolSemanticP7DsymbolP5Scope [0x55672d7d9b09]
??:? _ZN25ExpressionSemanticVisitor5visitEP14DeclarationExp [0x55672d837165]
??:? _ZN14DeclarationExp6acceptEP7Visitor [0x55672d81ca21]
??:? _Z18expressionSemanticP10ExpressionP5Scope [0x55672d84d50f]
??:? _ZN24StatementSemanticVisitor5visitEP12ExpStatement [0x55672d8ce49f]
??:? _ZN12ExpStatement6acceptEP7Visitor [0x55672d8caad5]
??:? _Z17statementSemanticP9StatementP5Scope [0x55672d8ce383]
??:? _ZN24StatementSemanticVisitor5visitEP17CompoundStatement [0x55672d8ce766]
??:? _ZN17CompoundStatement6acceptEP7Visitor [0x55672d8cafd1]
??:? _Z17statementSemanticP9StatementP5Scope [0x55672d8ce383]
??:? _ZN16Semantic3Visitor5visitEP15FuncDeclaration [0x55672d8c5206]
??:? _ZN15FuncDeclaration6acceptEP7Visitor [0x55672d857f61]
??:? _Z9semantic3P7DsymbolP5Scope [0x55672d8c3c4d]
??:? _ZN16Semantic3Visitor5visitEP6Module [0x55672d8c404e]
??:? _ZN6Module6acceptEP7Visitor [0x55672d7bb6d9]
??:? _Z9semantic3P7DsymbolP5Scope [0x55672d8c3c4d]
??:? int dmd.mars.tryMain(ulong, const(char)**, ref dmd.globals.Param)
[0x55672d7441f8]
??:? _Dmain [0x55672d745e35]

--
May 31 2022