[Issue 9506] New: When using alias this, writeln modifies its argument
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Feb 13 05:39:21 PST 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9506
Summary: When using alias this, writeln modifies its argument
Product: D
Version: D2
Platform: x86_64
OS/Version: Mac OS X
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: olli.pottonen at paivola.fi
--- Comment #0 from Olli Pottonen <olli.pottonen at paivola.fi> 2013-02-13 05:39:19 PST ---
The function writeln is not expected to modify its arguments, just print them.
However when a class uses alias this, writeln clears the member variable in
question.
Example:
import std.stdio;
class test {
uint[] _p;
alias _p this;
this() { _p = [1, 2]; }
}
void main()
{
test t = new test();
writeln(t);
writeln(t);
}
The expected output is
[1, 2]
[1, 2]
but instead the program outputs
[1, 2]
[]
--
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