May 26, 2013 [Issue 10168] New: Named tuple: inconsistent behavior | ||||
---|---|---|---|---|
| ||||
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 --- Comment #0 from Ryuichi OHORI <r.97all@gmail.com> 2013-05-25 18:07:05 PDT --- The code at the bottom outputs > S(314159265) > S(0) in DMD 2.062, http://dpaste.1azy.net/96d42b70 but > S(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 26, 2013 [Issue 10168] Named tuple: inconsistent behavior | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ryuichi OHORI | http://d.puremagic.com/issues/show_bug.cgi?id=10168 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs@eml.cc --- Comment #1 from bearophile_hugs@eml.cc 2013-05-26 05:30:08 PDT --- 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: ------- |
Copyright © 1999-2021 by the D Language Foundation