D-Scanner icon indicating copy to clipboard operation
D-Scanner copied to clipboard

don't check for 'could be immutable' if object methods are called

Open wilzbach opened this issue 8 years ago • 1 comments

Consider this example here:

import std.range: iota;
auto d = iota(2);
d.popFront;
assert(d.front == 1);
foo.d(5:10)[warn]: Variable d is never modified and could have been declared const or immutable.

And dmd obviously complains when adding immutable or const.

foo.d(6): Error: mutable method std.range.iota!(int, int).iota.Result.popFront is not callable using a immutable object

wilzbach avatar Apr 14 '16 06:04 wilzbach

This feature was already implemented long ago. The problem is that from the AST you can't tell that d.popFront is a function call.

Hackerpilot avatar Apr 18 '16 01:04 Hackerpilot