[Issue 9404] Nullable is unusable with 2.061
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jan 30 23:19:49 PST 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9404
--- Comment #7 from monarchdodra at gmail.com 2013-01-30 23:19:47 PST ---
(In reply to comment #6)
> https://github.com/D-Programming-Language/dmd/pull/1585
> https://github.com/D-Programming-Language/phobos/pull/1105
>
> ---
>
> (In reply to comment #2)
> > ----------------
> > The real question is: Why did the first example ever work at all? I've tracked
> > it down to this usecase, with *at least*, a 3-level nest:
> >
> > //----
> > import std.typecons;
> > import std.stdio;
> >
> > struct S
> > {
> > void opAssign(int){writeln("opAssign");}
> > int get(){writeln("get"); return 1;}
> > alias get this;
> > }
> >
> > struct SS
> > {
> > S s;
> > }
> >
> > struct SSS
> > {
> > SS ss;
> > this(SS i)
> > {
> > ss = i;
> > }
> > }
> >
> > void main() {
> > SS ss;
> > SSS(ss);
> > }
> > //----
> >
> > DMD 2.060:
> > //----
> > //----
> >
> > DMD 2.061:
> > //----
> > get
> > opAssign
> > //----
> >
> > AFAIK, 2.061 is the correct behavior. Something must have been fixed in 2.061,
> > so that explains the *change* in behavior. So there should be nothing to fix
> > there... But I'll let own of the compiler guys confirm.
> >
> > In any case, I'll fix open a pull to improve Nullable to accept assignment from
> > another nullable.
>
> Yes, it is intended behavior in 2.061. The pull request had merged:
> https://github.com/D-Programming-Language/dmd/pull/166
> Was for implementing it.
>
> But, sorry, it was not complete. In 2.061, user-defined opAssign is now
> _overly_ considered and used for the identity assignment. It is a compiler
> regression.
>
> In this case, Nullable!T should generate bitwise copy for identity assignment.
>
> > alias N = Nullable!int;
> > void foo(N a) {
> > N b;
> > b = a; // must be bitwise, must not invoke Nullable!int.opAssign(int)
> > }
>
> If the assignment is not identity, user-defined opAssing should be called.
>
> void foo(N a) {
> N b;
> b = 1; // b.opAssign(1) is called
> b = ""; // b.opAssign("") is called, and compiler will cause an error
> }
My apologies for not linking back:
https://github.com/D-Programming-Language/phobos/pull/1103
This is now a useless pull... correct?
--
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