[dmd-beta] D 2.062 beta

Nick Sabalausky bus_dmdbeta at semitwist.com
Sat Feb 9 00:23:27 PST 2013


On Fri, 8 Feb 2013 18:25:27 -0500
Nick Sabalausky <bus_dmdbeta at semitwist.com> wrote:

> On Sat, 09 Feb 2013 00:13:34 +0100
> "Jonathan M Davis" <jmdavisProg at gmx.com> wrote:
> 
> > On Friday, February 08, 2013 18:00:11 Nick Sabalausky wrote:
> > > I am tracking down one or two other problems now though, looks
> > > like at least one of them has to do with toString on a struct...
> > 
> > IIRC, it was supposed to have been fixed semi-recently so that
> > toString on structs weren't so restrictive about their attributes
> > (e.g. making it const should now work), so that may be related
> > (though that might have been in 2.061; I don't remember).
> > 
> 
> Whatever problem it is I'm tracking down was indeed introduced in
> 2.061. Due to some unfortunate timing, I didn't have a chance to test
> 2.061 during its beta.
> 
> The problem *seems* to involve a struct's toString not getting called
> by format(), but a trivial test of it seems to work fine. So I'm still
> narrowing it down...
> 
> There's also another problem I have with a certain opCmp not working
> right (as of 2.061), but it might turn out to be the same problem, or
> my own fault, or something else entirely. not sure yet...

One of the problems turned out to be the following, which I'm guessing
is probably intentional?:

    import std.stdio;
    
    struct Foo
    {
        string toString()
        {
            return "hello";
        }
    }

    void main()
    {
        const f = Foo();

        // In 2.061 and up, this outputs "const(Foo)()"
        // instead of "hellO". A fixed bug?
        writeln(f);
    }

Making toString 'const' seems to make the problem go away, so I'm
guessing this is as intended. Kind of a pain though, as it means
the const-version of a struct can easily end up with accidentally
different behavior.

I'm still tracking down the other problem I'm having, involving a
struct that no longer works correctly as an AA key (again, as of
2.061, but still failing in this beta). I have a feeling this may be a
const-ness problem too, though I'm not certain yet.


More information about the dmd-beta mailing list