Thread overview | |||||
---|---|---|---|---|---|
|
October 14, 2012 [Issue 8815] New: alias modification silently fails on nested fields | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=8815 Summary: alias modification silently fails on nested fields Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: andrej.mitrovich@gmail.com --- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-10-13 19:48:21 PDT --- @property void modify(alias symb)() { symb = new int; } class Foo { this() { modify!(x); modify!(c.x); assert(x); // ok assert(c.x); // fail, c.x. is null } static struct C { int* x; } C c; int* x; } void main() { auto foo = new Foo; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 14, 2012 [Issue 8815] alias modification silently fails on nested fields | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=8815 --- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-10-13 19:59:26 PDT --- But I'm beginning to think using aliases like this isn't the best choice. For one thing it won't work if the alias is a private symbol. It's probably best to use templated functions that take a 'ref' parameter. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 26, 2013 [Issue 8815] alias modification silently fails on nested fields | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=8815 --- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-01-26 14:05:49 PST --- I can see why, it seems "c.x" gets converted to "this.x": @property void init(alias symb)() { pragma(msg, symb); // "this.x", should be "s.x" symb = new int; } class C { this() { init!(s.x); } struct S { int* x; } S s; } void main() { auto c = new C; } Additionally I get this in this sample: core.exception.InvalidMemoryOperationError -- 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