Calls to struct methods and immutable
Joseph Rushton Wakeling
joseph.wakeling at webdrake.net
Thu Nov 15 10:26:29 PST 2012
On 11/15/2012 06:40 PM, Ali Çehreli wrote:
> b) The user wants to play safe:
>
> auto makeFoo()
> {
> Foo foo;
> foreach (i; 0..10)
> foo.add( /* new data point */ );
> return foo;
> }
>
> void main()
> {
> immutable foo = makeFoo();
> }
>
> Both of those compile with dmd 2.060.
Really? I'm using from-GitHub dmd, and with the above example I get a "cannot
implicitly convert expression to immutable" error, e.g.:
Error: cannot implicitly convert expression (testSets(nfRaw,0.1L)) of type
TestData!(ulong,ulong) to immutable(TestData!(ulong,ulong))
More information about the Digitalmars-d-learn
mailing list