November 16, 2023 [Issue 24248] New: const constructor with mutable target gives wrong error message | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24248 Issue ID: 24248 Summary: const constructor with mutable target gives wrong error message Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: nick@geany.org struct S2 { this(int) const {} int* i; } void main() { S2 s2 = S2(5); } Error: constructor `const_ctor.S2.this(int __param_0) const` is not callable using argument types `(int)` Which is confusing as the only parameter the user sees does actually match correctly. It should instead say: Error: `const` constructor `const_ctor.S2.this` cannot construct a mutable object Which is the style of wording you get if the constructor is declared as immutable (actually after issue #24247 is fixed, but even without that the status quo is for immutable is much better than for const). PR incoming. -- |
Copyright © 1999-2021 by the D Language Foundation