Bug 20753 – "Error: unknown" with structs of arrays, speculative instantiation and recursive types

Status
ASSIGNED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-04-20T04:18:30Z
Last change time
2024-12-13T19:08:14Z
Keywords
ice, rejects-valid
Assigned to
No Owner
Creator
Vladimir Panteleev
Moved to GitHub: dmd#19694 →

Comments

Comment #0 by dlang-bugzilla — 2020-04-20T04:18:30Z
//////////////// test.d //////////////// struct HashCollection() { struct Item { IniFragment value; } Item[] items; ref lookupToReturnValue() { return items[0].value; } enum canDup = is(typeof(items.dup)); } struct IniFragment { HashCollection!() children; } //////////////////////////////////////// Works in DMD 2.085 but not newer. Bisecting shows that the error message begins manifesting when it was introduced ( https://github.com/dlang/dmd/pull/9425 ), however debug versions of DMD have been failing with an assertion failure before that change. The assertion failures began after https://github.com/dlang/dmd/pull/5500 .
Comment #1 by ibuclaw — 2020-05-04T13:16:09Z
How are you building dmd? I first tried a debug version of v2.085.1, and I hit an assert on the test. core.exception.AssertError@dmd/statement.d(449): Assertion failure ---------------- ??:? _d_assertp [0xab84b225] ??:? dmd.statement.ErrorStatement dmd.statement.ErrorStatement.__ctor() [0xab724c25] ??:? _ZN24StatementSemanticVisitor8setErrorEv [0xab745f87] ??:? _ZN24StatementSemanticVisitor5visitEP12ExpStatement [0xab746172] ??:? _ZN12ExpStatement6acceptEP7Visitor [0xab725739] ??:? _Z17statementSemanticP9StatementP5Scope [0xab745f32] ??:? _ZN24StatementSemanticVisitor5visitEP17CompoundStatement [0xab74630b] ??:? _ZN17CompoundStatement6acceptEP7Visitor [0xab725f99] ??:? _Z17statementSemanticP9StatementP5Scope [0xab745f32] ??:? _ZN16Semantic3Visitor5visitEP15FuncDeclaration [0xab75b088] ??:? _ZN15FuncDeclaration6acceptEP7Visitor [0xab6b371d] ??:? _Z9semantic3P7DsymbolP5Scope [0xab7599b4] ??:? _ZN16Semantic3Visitor5visitEP16TemplateInstance [0xab759b54] ??:? _ZN16TemplateInstance6acceptEP7Visitor [0xab675fd9] ??:? _Z9semantic3P7DsymbolP5Scope [0xab7599b4] ??:? void dmd.dtemplate.TemplateInstance.trySemantic3(dmd.dscope.Scope*) [0xab675f92] ??:? void dmd.dsymbolsem.templateInstanceSemantic(dmd.dtemplate.TemplateInstance, dmd.dscope.Scope*, dmd.root.array.Array!(dmd.expression.Expression).Array*) [0xab663435] ??:? _ZN22DsymbolSemanticVisitor5visitEP16TemplateInstance [0xab6598a6] ??:? _ZN16TemplateInstance6acceptEP7Visitor [0xab675fd9] ??:? _Z15dsymbolSemanticP7DsymbolP5Scope [0xab6528ec] ??:? _ZN25ExpressionSemanticVisitor5visitEP8ScopeExp [0xab693d9e] ??:? _ZN8ScopeExp6acceptEP7Visitor [0xab6827a5] ??:? _Z18expressionSemanticP10ExpressionP5Scope [0xab6abd9e] ??:? _ZN25ExpressionSemanticVisitor5visitEP7CallExp [0xab696bcf] ??:? _ZN7CallExp6acceptEP7Visitor [0xab6865f9] ??:? _Z18expressionSemanticP10ExpressionP5Scope [0xab6abd9e] ??:? _ZN24StatementSemanticVisitor5visitEP15ReturnStatement [0xab74fbae] ??:? _ZN15ReturnStatement6acceptEP7Visitor [0xab727c25] ??:? _Z17statementSemanticP9StatementP5Scope [0xab745f32] ??:? _ZN24StatementSemanticVisitor5visitEP17CompoundStatement [0xab74630b] ??:? _ZN17CompoundStatement6acceptEP7Visitor [0xab725f99] ??:? _Z17statementSemanticP9StatementP5Scope [0xab745f32] ??:? _ZN16Semantic3Visitor5visitEP15FuncDeclaration [0xab75b088] ??:? _ZN15FuncDeclaration6acceptEP7Visitor [0xab6b371d] ??:? _Z9semantic3P7DsymbolP5Scope [0xab7599b4] ??:? _ZN15FuncDeclaration17functionSemantic3Ev [0xab6aee4d] ??:? _ZN15FuncDeclaration16functionSemanticEv [0xab6aed63] ??:? dmd.func.FuncDeclaration dmd.func.resolveFuncCall(ref const(dmd.globals.Loc), dmd.dscope.Scope*, dmd.dsymbol.Dsymbol, dmd.root.array.Array!(dmd.root.rootobject.RootObject).Array*, dmd.mtype.Type, dmd.root.array.Array!(dmd.expression.Expression).Array*, dmd.func.FuncResolveFlag) [0xab6b3ef7] ??:? _ZN25ExpressionSemanticVisitor5visitEP7CallExp [0xab698bef] ??:? _ZN7CallExp6acceptEP7Visitor [0xab6865f9] ??:? _Z18expressionSemanticP10ExpressionP5Scope [0xab6abd9e] ??:? dmd.expression.Expression dmd.expressionsem.resolveUFCSProperties(dmd.dscope.Scope*, dmd.expression.Expression, dmd.expression.Expression) [0xab68ccb1] ??:? _ZN25ExpressionSemanticVisitor5visitEP8DotIdExp [0xab69ce24] ??:? _ZN8DotIdExp6acceptEP7Visitor [0xab68588d] ??:? _Z18expressionSemanticP10ExpressionP5Scope [0xab6abd9e] ??:? void dmd.typesem.resolve(dmd.mtype.Type, ref const(dmd.globals.Loc), dmd.dscope.Scope*, dmd.expression.Expression*, dmd.mtype.Type*, dmd.dsymbol.Dsymbol*, bool).visitTypeof(dmd.mtype.TypeTypeof) [0xab732aad] ??:? void dmd.typesem.resolve(dmd.mtype.Type, ref const(dmd.globals.Loc), dmd.dscope.Scope*, dmd.expression.Expression*, dmd.mtype.Type*, dmd.dsymbol.Dsymbol*, bool) [0xab731dd4] ??:? dmd.mtype.Type dmd.typesem.typeSemantic(dmd.mtype.Type, dmd.globals.Loc, dmd.dscope.Scope*).visitTypeof(dmd.mtype.TypeTypeof) [0xab72ff26] ??:? _Z12typeSemanticP4Type3LocP5Scope [0xab72d0bd] ??:? _ZN4Type11trySemanticERK3LocP5Scope [0xab6f65f5] ??:? _ZN25ExpressionSemanticVisitor5visitEP5IsExp [0xab69a926] ??:? _ZN5IsExp6acceptEP7Visitor [0xab684365] ??:? _Z18expressionSemanticP10ExpressionP5Scope [0xab6abd9e] ??:? dmd.init.Initializer dmd.initsem.inferType(dmd.init.Initializer, dmd.dscope.Scope*).visitExp(dmd.init.ExpInitializer) [0xab6cb057] ??:? dmd.init.Initializer dmd.initsem.inferType(dmd.init.Initializer, dmd.dscope.Scope*) [0xab6caa9f] ??:? _ZN22DsymbolSemanticVisitor5visitEP14VarDeclaration [0xab653265] ??:? _ZN14VarDeclaration6acceptEP7Visitor [0xab61efe9] ??:? _Z15dsymbolSemanticP7DsymbolP5Scope [0xab6528ec] ??:? void dmd.dsymbolsem.DsymbolSemanticVisitor.visit(dmd.dstruct.StructDeclaration).__lambda5!(dmd.dsymbol.Dsymbol).__lambda5(dmd.dsymbol.Dsymbol) [0xab65f40f] ??:? void dmd.dsymbol.foreachDsymbol(dmd.root.array.Array!(dmd.dsymbol.Dsymbol).Array*, void delegate(dmd.dsymbol.Dsymbol)) [0xab64cd73] ??:? _ZN22DsymbolSemanticVisitor5visitEP17StructDeclaration [0xab65ed85] ??:? _ZN17StructDeclaration6acceptEP7Visitor [0xab64c819] ??:? _Z15dsymbolSemanticP7DsymbolP5Scope [0xab6528ec] ??:? void dmd.dtemplate.TemplateInstance.expandMembers(dmd.dscope.Scope*).symbolDg(dmd.dsymbol.Dsymbol) [0xab675eb4] ??:? void dmd.dsymbol.foreachDsymbol(dmd.root.array.Array!(dmd.dsymbol.Dsymbol).Array*, void delegate(dmd.dsymbol.Dsymbol)) [0xab64cd73] ??:? void dmd.dtemplate.TemplateInstance.expandMembers(dmd.dscope.Scope*) [0xab675e40] ??:? void dmd.dtemplate.TemplateInstance.tryExpandMembers(dmd.dscope.Scope*) [0xab675f1e] ??:? void dmd.dsymbolsem.templateInstanceSemantic(dmd.dtemplate.TemplateInstance, dmd.dscope.Scope*, dmd.root.array.Array!(dmd.expression.Expression).Array*) [0xab662f79] ??:? _ZN22DsymbolSemanticVisitor5visitEP16TemplateInstance [0xab6598a6] ??:? _ZN16TemplateInstance6acceptEP7Visitor [0xab675fd9] ??:? _Z15dsymbolSemanticP7DsymbolP5Scope [0xab6528ec] ??:? void dmd.typesem.resolve(dmd.mtype.Type, ref const(dmd.globals.Loc), dmd.dscope.Scope*, dmd.expression.Expression*, dmd.mtype.Type*, dmd.dsymbol.Dsymbol*, bool).visitInstance(dmd.mtype.TypeInstance) [0xab732929] ??:? void dmd.typesem.resolve(dmd.mtype.Type, ref const(dmd.globals.Loc), dmd.dscope.Scope*, dmd.expression.Expression*, dmd.mtype.Type*, dmd.dsymbol.Dsymbol*, bool) [0xab731dc6] ??:? dmd.mtype.Type dmd.typesem.typeSemantic(dmd.mtype.Type, dmd.globals.Loc, dmd.dscope.Scope*).visitInstance(dmd.mtype.TypeInstance) [0xab72fe1e] ??:? _Z12typeSemanticP4Type3LocP5Scope [0xab72d0ab] ??:? _ZN22DsymbolSemanticVisitor5visitEP14VarDeclaration [0xab65336f] ??:? _ZN14VarDeclaration6acceptEP7Visitor [0xab61efe9] ??:? _Z15dsymbolSemanticP7DsymbolP5Scope [0xab6528ec] ??:? void dmd.dsymbolsem.DsymbolSemanticVisitor.visit(dmd.dstruct.StructDeclaration).__lambda5!(dmd.dsymbol.Dsymbol).__lambda5(dmd.dsymbol.Dsymbol) [0xab65f40f] ??:? void dmd.dsymbol.foreachDsymbol(dmd.root.array.Array!(dmd.dsymbol.Dsymbol).Array*, void delegate(dmd.dsymbol.Dsymbol)) [0xab64cd73] ??:? _ZN22DsymbolSemanticVisitor5visitEP17StructDeclaration [0xab65ed85] ??:? _ZN17StructDeclaration6acceptEP7Visitor [0xab64c819] ??:? _Z15dsymbolSemanticP7DsymbolP5Scope [0xab6528ec] ??:? void dmd.dsymbolsem.DsymbolSemanticVisitor.visit(dmd.dmodule.Module).__lambda2!(dmd.dsymbol.Dsymbol).__lambda2(dmd.dsymbol.Dsymbol) [0xab657c67] ??:? void dmd.dsymbol.foreachDsymbol(dmd.root.array.Array!(dmd.dsymbol.Dsymbol).Array*, void delegate(dmd.dsymbol.Dsymbol)) [0xab64cd73] ??:? _ZN22DsymbolSemanticVisitor5visitEP6Module [0xab657bf3] ??:? _ZN6Module6acceptEP7Visitor [0xab63e9b5] ??:? _Z15dsymbolSemanticP7DsymbolP5Scope [0xab6528ec] ??:? int dmd.mars.tryMain(ulong, const(char)**, ref dmd.globals.Param) [0xab6ededf] ??:? _Dmain [0xab6ef480]
Comment #2 by ibuclaw — 2020-05-04T13:25:06Z
(In reply to Iain Buclaw from comment #1) > How are you building dmd? I first tried a debug version of v2.085.1, and I > hit an assert on the test. > Ah, I failed to read the last sentence. So the regression is in fact caused by pr5500, and pr9485 only partially solved the problem by no longer ICE'ing.
Comment #3 by razvan.nitu1305 — 2021-11-26T12:29:42Z
Running the code on run.dlang.io [1], it seems that at some point this code compiled, but then it issued an error which was transformed into an ICE. So by "Works in DMD 2.085 but not newer.", I guess you mean that a proper error is outputted? I can't imagine how this used to work we have a mutual dependency at semantic between HashCollection and IniFragment. [1] https://github.com/dlang/dmd/pull/13348#issuecomment-979940003
Comment #4 by razvan.nitu1305 — 2021-11-26T12:30:23Z
(In reply to RazvanN from comment #3) > Running the code on run.dlang.io [1], it seems that at some point this code > compiled, but then it issued an error which was transformed into an ICE. So > by "Works in DMD 2.085 but not newer.", I guess you mean that a proper error > is outputted? I can't imagine how this used to work we have a mutual > dependency at semantic between HashCollection and IniFragment. > > [1] https://github.com/dlang/dmd/pull/13348#issuecomment-979940003 I'm sorry, but I messed up the link. The proper link is: https://run.dlang.io/is/2qlZvz
Comment #5 by dlang-bugzilla — 2021-11-26T12:36:12Z
(In reply to RazvanN from comment #3) > Running the code on run.dlang.io [1], it seems that at some point this code > compiled, but then it issued an error which was transformed into an ICE. So > by "Works in DMD 2.085 but not newer.", I guess you mean that a proper error > is outputted? I can't imagine how this used to work we have a mutual > dependency at semantic between HashCollection and IniFragment. By "works" here I meant "does not crash with -o-", but it does result in various errors with -c. With -c, it succeeds in the version range 2.066.0 to 2.071.2.
Comment #6 by robert.schadek — 2024-12-13T19:08:14Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19694 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB