Bug 24618 – redefined core type errors should show fully qualified name

Status
NEW
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-06-20T02:50:51Z
Last change time
2024-12-13T19:35:50Z
Keywords
diagnostic
Assigned to
No Owner
Creator
Steven Schveighoffer
Moved to GitHub: dmd#18248 →

Comments

Comment #0 by schveiguy — 2024-06-20T02:50:51Z
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.
Comment #1 by robert.schadek — 2024-12-13T19:35:50Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18248 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB