[Issue 19028] New: Emit warning for identifiers starting with `__`
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jun 26 08:31:41 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=19028
Issue ID: 19028
Summary: Emit warning for identifiers starting with `__`
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: regnellday at protonmail.com
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/yauflbmphapnnksckksu@forum.dlang.org
--
More information about the Digitalmars-d-bugs
mailing list