Bug 7744 – Forward reference in string mixin

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-03-20T20:16:00Z
Last change time
2013-11-23T21:35:12Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
jminer7

Comments

Comment #0 by jminer7 — 2012-03-20T20:16:58Z
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?
Comment #1 by k.hara.pg — 2013-11-22T00:27:30Z
(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
Comment #2 by github-bugzilla — 2013-11-23T21:34:50Z
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