digitalmars.D.bugs - [Issue 20073] New: Wrong implicit conversion for return type
- d-bugmail puremagic.com (32/32) Jul 22 2019 https://issues.dlang.org/show_bug.cgi?id=20073
https://issues.dlang.org/show_bug.cgi?id=20073 Issue ID: 20073 Summary: Wrong implicit conversion for return type Product: D Version: D2 Hardware: All URL: http://dlang.org/ OS: All Status: NEW Severity: major Priority: P3 Component: dmd Assignee: nobody puremagic.com Reporter: eyal weka.io It seems that some weird interaction between "alias this", "inout" and implicit return conversions is incorrectly allowing a conversion from an S instance, which isn't immutable, to an immutable(char)[]. Note the assignment is (correctly) rejected but the return is (incorrectly) allowed: struct S { char[10] x; auto slice() inout { return x[0 .. 10]; } alias slice this; } string test() { S s; string str = s; // cannot implicitly convert expression `s` of type `S` to `string` return s; // and suddenly we can! } I'd expect both the assignment and return to fail. --
Jul 22 2019