D-Scanner
D-Scanner copied to clipboard
don't check for 'could be immutable' if object methods are called
trafficstars
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
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.