Created attachment 1853 [details] 4 source modules The attached archive contains 4 dustmited modules. With DMD v2.100.0, all 4 modules can be individually compiled just fine. With `-allinst` however, compiling `variant.d` (alone) fails with: ----- rbtree.d(36): Error: `@safe` function `rbtree.RedBlackTree!(Pair, lessPairKeys).RedBlackTree.toHash` cannot call `@system` function `rbtree.RBRange!(RBNode!(Pair)*).RBRange.popFront` rbtree.d(22): `rbtree.RBRange!(RBNode!(Pair)*).RBRange.popFront` is declared here statictypes.d(12): Error: template instance `rbtree.RedBlackTree!(Pair, lessPairKeys)` error instantiating statictypes.d(15): instantiated from here: `Map!(string, SType)` ----- The 3 other modules compile fine with `-allinst` too. Prepending another root module works: `dmd -o- -allinst statictypes.d variant.d`. Swapping the root modules order makes it fail again: `dmd -o- -allinst variant.d statictypes.d`
I'm going to have a crack at this tonight.
Some printf debugging: Context: popFront exp: sym/rbtree.d(22):(*this._begin).next() Data about f: next sym/rbtree.d(9) (null) next has type RBNode!(Pair)*() setUnsafe: next setUnsafe: In progress sc.flag & compile: not setUnsafe: sym/rbtree.d(9) popFront setUnsafe: In progress FuncDeclaration::semantic3(function 'next', sc = 0x7f7eb91f03d0) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Semantic3 is on next run *after* its first use.
RBNode has it's AggregateDecl semantic3 done far far too late. I've checked for plain memory corruption, I think this is something trying to be clever and failing (as per usual).
The 2 failing cmdlines work when disabling an apparent hack in https://github.com/dlang/dmd/blob/e2b4fb6d8a60ef33f5bbc6309e250024bbebb1a0/compiler/src/dmd/func.d#L441-L450.
Related issue: https://issues.dlang.org/show_bug.cgi?id=17541