Created attachment 1853
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`
Comment #1 by maxhaton — 2022-05-19T21:34:18Z
I'm going to have a crack at this tonight.
Comment #2 by maxhaton — 2022-05-20T01:27:42Z
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.
Comment #3 by maxhaton — 2022-05-20T02:23:38Z
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).