[Issue 9281] Enum struct with op overloading doesnt works

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 10 07:42:46 PST 2013


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



--- Comment #2 from Daniel Kozak <kozzi11 at gmail.com> 2013-01-10 07:42:45 PST ---
(In reply to comment #1)
> Did this really work with 2.060? I cannot reproduce the "works 2.060".
> 
> Column.opAssign is an immutable member function, then we can call it from
> immutable object test1, but cannot call from mutable object test2.
> 
> So, the error in test2 = "something else" is correct, as far as I know.

Yes my fault, I try to simplify too much. Here is more detailed description

Code which works on 2.060 and don`t compile on 2.061

module main;

import std.algorithm;
import std.array;

immutable struct Column {

    string opAssign(V)(V tValue) {
        return tValue;
    }
}

class Ob2 {
    enum : Column {
        COLUM_A = Column()
    }

    immutable COLUMNS = [
        COLUM_A,
    ];
}

immutable test1 = Column();

void main(string[] args)
{
    string where = test1 = "something"; // works ok
    std.stdio.writeln(where);
    where = (Ob2.COLUM_A = "something else"); // works 2.060, dont compile on
2.061
    std.stdio.writeln(where);
}


However I find out more interesing thing. This code is almost same however it
doesn`t work on 2.061 neither 2.060:

module main;

import std.algorithm;
import std.array;

immutable struct Column {

    string opAssign(V)(V tValue) {
        return tValue;
    }
}

class Ob2 {
    enum : Column {
        COLUM_A = Column()
    }

    // comment this code make it not compilable in 2.060
    /*immutable COLUMNS = [
        COLUM_A,
    ];*/
}

immutable test1 = Column();

void main(string[] args)
{
    string where = test1 = "something"; // works ok
    std.stdio.writeln(where);
    where = (Ob2.COLUM_A = "something else"); // dont compile on 2.060 and
2.061
    std.stdio.writeln(where);
}

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


More information about the Digitalmars-d-bugs mailing list