digitalmars.D - Variables should probably not shadow parent methods
- qznc (16/16) Jul 12 2016 Just seen on Reddit [0] and there are a few more examples.
Just seen on Reddit [0] and there are a few more examples. class Test { string function() toString = function() { return "one"; }; } void main() { auto test = new Test; writeln(test); test.toString = function() { return "two"; }; writeln(cast(Object)test); } Test has a delegate field `toString` which shadows the method `toString` inherited from Object. Could we make this an error? [0] https://www.reddit.com/r/d_language/comments/4sfcv8/overriding_parents_member_function_with_anonymous/
Jul 12 2016