digitalmars.D.bugs - [Issue 10168] New: Named tuple: inconsistent behavior
- d-bugmail puremagic.com (38/42) May 25 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10168
- d-bugmail puremagic.com (24/24) May 26 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10168
http://d.puremagic.com/issues/show_bug.cgi?id=10168 Summary: Named tuple: inconsistent behavior Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: r.97all gmail.com --- The code at the bottom outputsS(314159265) S(0)in DMD 2.062, http://dpaste.1azy.net/96d42b70 butS(0) S(314159265)in another version, http://dpaste.1azy.net/edc065ea I think right output is S(314159265) repeated 2 times. ----- import std.stdio; import std.typecons : Tuple; struct S { int x; Tuple!(S, "x") toTuple() { return Tuple!(S, "x")(this); } } void main() { auto y = S(314159265).toTuple(); y[0].writeln(); y.x.writeln(); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 25 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10168 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs eml.cc Also this similar program gives an unusual error message: import std.stdio: writeln; import std.typecons: Tuple; struct Foo { int x; Tuple!(Foo, "x") toTuple() { return Tuple!(Foo, "x")(this); } } void main() { auto y = Foo(100).toTuple; y[1].writeln; // line 11 y.x.writeln; } temp.d(11): Error: no [] operator overload for type Tuple!(Foo, "x") -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 26 2013