Does opSlice work with immutable values?

Joseph Cassman jc7919 at outlook.com
Sun Feb 23 23:01:58 PST 2014


I have a custom number type in the works here 
(https://github.com/joichiro/kuttaka/commit/a226d3368a64ae63b0c256c4f4a4ede375a5cee8). 
The test code for opSlice works in this commit. However, when I 
change the auto to immutable (on line 308) I get the following 
error (a similar error occurs for const):

src/bcd.d(309): Error: mutable method 
kuttaka.bcd.BcdSingle.opSlice is not callable using a immutable 
object
src/bcd.d(310): Error: mutable method 
kuttaka.bcd.BcdSingle.opSlice is not callable using a immutable 
object
src/bcd.d(311): Error: mutable method 
kuttaka.bcd.BcdSingle.opSlice is not callable using a immutable 
object
Failed: ["dmd", "-unittest", "-v", "-o-", "src/bcd.d", "-Isrc"]

How can I get immutable to work here? My thinking is that opSlice 
is creating a new object here so the sliced object should be 
allowed to be const or immutable.

I am using the current HEAD revision of the DMD compiler 
toolchain.

Joseph



More information about the Digitalmars-d-learn mailing list