May 24 [Issue 24563] New: Make the compiler provide a reason for why it has disabled a function | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24563 Issue ID: 24563 Summary: Make the compiler provide a reason for why it has disabled a function Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: issues.dlang@jmdavisProg.com Currently, whenever the compiler is unable to generate a function that it would normally generate for a type (e.g. a copy constructor, because it has a member variable with a copy constructor, or an opAssign, because it has a member variable with an overloaded opAssign), it seems to just mark it as @disable as if the user had explicitly written the function prototype and then marked it with @disable. The result of this is that when you try to use such an operation on a type, you get an extremely uninformative error message - e.g. from https://issues.dlang.org/show_bug.cgi?id=24562: --- q.d(36): Error: generated function `q.main.S2.opAssign` cannot be used because it is annotated with `@disable` --- It _is_ fortunately smart enough to say that it's a generated function, but it says nothing about why opAssign has been disabled. This can make it extremely difficult to figure out what the actual problem is, and I'm unaware of any way to get that information short of running the compiler through a debugger. So, please fix it so that when the compiler says that a generated function was disabled, it explains _why_ it was disabled, so that we have some hope of actually figuring out what the problem is and how to fix it. In some cases, it might be a simple fix on the programmer's part, whereas in others, it could be a compiler bug. Either way, there's no hint as to what the problem could be. The compiler has basically just said that it failed without giving an actual reason. -- |
Copyright © 1999-2021 by the D Language Foundation