Bug 19028 – Emit warning for identifiers starting with `__`

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-06-26T08:31:41Z
Last change time
2024-12-13T18:59:19Z
Assigned to
No Owner
Creator
dayllenger
Moved to GitHub: dmd#19450 →

Comments

Comment #0 by regnellday — 2018-06-26T08:31:41Z
Identifiers starting with `__` are reserved for compiler and their behaviour is implementation-defined. But compilers do not show warning or error message when you try to use such names. Furthermore, some functions ignore these identifiers and may produce hidden bugs in a code. For example: void main() { writeln([__traits(allMembers, S)]); // will print only ["a"] } struct S { int a; int __refCount; } Documentation of `allMembers` says nothing about this behaviour. Links: https://dlang.org/spec/lex.html#identifiers https://dlang.org/spec/traits.html#allMembers https://github.com/dlang/dmd/blob/2ce74fc1180a3b0ed5e5c29aa79bf3773af5d5b7/src/dmd/traits.d#L1385 https://forum.dlang.org/thread/[email protected]
Comment #1 by schveiguy — 2018-06-26T14:35:39Z
My suggestion is to only emit warnings for packages that are not owned by the language. In other words, the language should be free to add these types of symbols in std.*, rt.*, core.*, and object without complaint.
Comment #2 by robert.schadek — 2024-12-13T18:59:19Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19450 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB