----- import std.stdio; struct Set { int[int] set; auto walk () { return this.set.byKey(); } alias walk this; } void main() { Set set; set.set[1] = 10; writefln("Set contents: %s", set.set.byKey()); // ok writefln("Set contents: %s", set); // prints "1" infinitely } ----- Tested with v2.086.1 and v2.088.0
I think, the bug is to be found in dmd and byKey is innocent. If not, the correct component is not phobos but druntime, because byKey is located there.
Simpler example: ----- import std.stdio; import std.range; struct Set { auto walk () { return [].only; } alias walk this; } void main() { Set set; writeln(set); } ----- It has to do with ranges, not specifically hashmaps as previously thought. I think somewhere in the formatter it's probably trying to invoke walk() multiple times, implicitly through that 'alias this'.
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19625 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB