[Issue 24618] New: redefined core type errors should show fully qualified name
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jun 20 02:50:51 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24618
Issue ID: 24618
Summary: redefined core type errors should show fully qualified
name
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: diagnostic
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: schveiguy at gmail.com
Some types in D are considered core to the language, but are defined in the
library. For example:
size_t
ptrdiff_t
string
Object
TypeInfo
One can redefine these symbols in a module, but the resulting confusion in the
error messages is really hard to parse by the person reading the message.
For example, I stared at an error message for about 20 minutes thinking I had a
broken compiler that looked like this:
cannot pass argument `(*aa.impl).keysz` of type `immutable(uint)` to parameter
`size_t len`
Of course, a normal immutable uint can be converted to a normal size_t. But I
had accidentally redefined size_t to an enum.
My suggestion is to prefix any symbols that shadow ones defined in object.d
with the fully qualified name. This could be based on a chart of core symbols
like string or size_t, or it could be all symbols.
So if an error message is referring to a locally-defined size_t, it could say
instead:
cannot pass argument `(*aa.impl).keysz` of type `immutable(uint)` to parameter
`local.mod.size_t len`
This at least gives a hint that the type is not the size_t you are expecting.
--
More information about the Digitalmars-d-bugs
mailing list