www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7744] New: Crash with forward reference in string mixin

http://d.puremagic.com/issues/show_bug.cgi?id=7744

           Summary: Crash with forward reference in string mixin
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: jminer7 gmail.com


--- Comment #0 from Jordan Miner <jminer7 gmail.com> 2012-03-20 20:16:58 PDT ---
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?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 20 2012