digitalmars.D.bugs - [Issue 9281] New: Enum struct with op overloading doesnt works
- d-bugmail puremagic.com (33/33) Jan 08 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9281
- d-bugmail puremagic.com (9/9) Jan 10 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9281
- d-bugmail puremagic.com (61/67) Jan 10 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9281
- d-bugmail puremagic.com (16/23) Jan 10 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9281
- d-bugmail puremagic.com (22/26) Jan 10 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9281
http://d.puremagic.com/issues/show_bug.cgi?id=9281 Summary: Enum struct with op overloading doesnt works Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: regression Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: kozzi11 gmail.com module main; import std.algorithm; import std.array; immutable struct Column { string opAssign(V)(V tValue) { return tValue; } } immutable test1 = Column(); enum test2 = Column(); void main(string[] args) { string where = test1 = "something"; // works ok std.stdio.writeln(where); where = test2 = "something else"; // works 2.060, dont compile on 2.061 std.stdio.writeln(where); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 08 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9281 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. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 10 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9281Did 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: -------
Jan 10 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9281Yes 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[snip] The reason why (Ob2.COLUM_A = "something else") doesn't work in 2.061 is same immutable opAssign from that.However I find out more interesing thing. This code is almost same however it doesn`t work on 2.061 neither 2.060:[snip] I think this _was_ an accepts-invalid bug in 2.060. If you define Ob2.COLUMNS in 2.060, Ob2.COLUM_A is _incorrectly_ typed as immutable(Column). This is definitely a bug (But I don't know what change is fixed the bug in 2.060). So, this is not a regression. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 10 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9281 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALIDI think this _was_ an accepts-invalid bug in 2.060. If you define Ob2.COLUMNS in 2.060, Ob2.COLUM_A is _incorrectly_ typed as immutable(Column). This is definitely a bug (But I don't know what change is fixed the bug in 2.060).I found a commit which the behavior is changed. https://github.com/D-Programming-Language/dmd/commit/e01eb59f842dfe7a5275d96c420691c4a64f57f4 The root cause of the bug 5779 was an optimizer bug. If the type of an optimized result is different from the type of a source expression, the source expression type had been accidentally modified. In this case, the declaration of COLUMNS invokes optimizer on the expression [ COLUM_A, ], and it accidentally modified the type of COLUM_A to immutable(Column). So the conclusion is: the original code had an accepts-invalid bug, and it was already fixed in 2.061. I'll mark this as "resolved-invalid" bug. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 10 2013