Hi, I was working on a grammar with Pegged and dmd crashed. I reduced it to: class ZeroOrMore(Expr) { enum name = "ZeroOrMore!("~Expr.name~")"; } class Range(char begin, char end) { enum name = "Range!("~begin~","~end~")"; } mixin(q{ class RubySource : ZeroOrMore!(DecLiteral) { } class DecLiteral : Range!('0','9') { } }); void main() { } I get this error, followed by dmd crashing: dmd_crash.d(13): Error: class dmd_crash.DecLiteral is forward referenced when looking for 'name' If RubySource and DecLiteral are entered normally (not as a string mixin), then the code compiles. I tried reducing it a bit more: class ZeroOrMore(Expr) { enum name = "ZeroOrMore!("~Expr.name~")"; } mixin(q{ alias ZeroOrMore!(DecLiteral) foo; class DecLiteral { enum name = "Range!("~begin~","~end~")"; } }); void main() { } However, then I get a *large* number of errors: dmd_crash.d(32): Error: class dmd_crash.DecLiteral is forward referenced when looking for 'name' dmd_crash.d(32): Error: class dmd_crash.DecLiteral is forward referenced when looking for 'opDot' dmd_crash.d(32): Error: class dmd_crash.DecLiteral is forward referenced when looking for 'opDispatch' dmd_crash.d(32): Error: class dmd_crash.DecLiteral is forward referenced when looking for 'ame' dmd_crash.d(32): Error: class dmd_crash.DecLiteral is forward referenced when looking for 'nme' dmd_crash.d(32): Error: class dmd_crash.DecLiteral is forward referenced when looking for 'nae' dmd_crash.d(32): Error: class dmd_crash.DecLiteral is forward referenced when looking for 'nam' dmd_crash.d(32): Error: class dmd_crash.DecLiteral is forward referenced when looking for 'anme' ... For thousands of lines. I waited a little while, then killed dmd. Both of these examples are valid code, right?
(In reply to comment #0) > Hi, I was working on a grammar with Pegged and dmd crashed. I reduced it to: > > class ZeroOrMore(Expr) > { > enum name = "ZeroOrMore!("~Expr.name~")"; > } > class Range(char begin, char end) > { > enum name = "Range!("~begin~","~end~")"; > } > mixin(q{ > class RubySource : ZeroOrMore!(DecLiteral) > { > } > class DecLiteral : Range!('0','9') > { > } > }); > void main() { > } > > I get this error, followed by dmd crashing: > > dmd_crash.d(13): Error: class dmd_crash.DecLiteral is forward referenced when > looking for 'name' With git head, crash does not occur anymore. However compilation still wrongly fails. https://github.com/D-Programming-Language/dmd/pull/2853
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/b99f712f40ef15f94facceb4e7ee26bc8ba339a0 fix Issue 7744 - Forward reference in string mixin https://github.com/D-Programming-Language/dmd/commit/69dcaa99041925877006636f244fd7e814781d92 Merge pull request #2853 from 9rnsr/fix7744 Issue 7744 - Forward reference in string mixin