Thread overview
[Issue 10100] Identifiers with double underscores and allMembers
Nov 29, 2016
Ethan Watson
Jun 11, 2017
Iain Buclaw
Dec 25, 2019
Iain Buclaw
Dec 25, 2019
Dlang Bot
Dec 26, 2019
Dlang Bot
Feb 20, 2020
Dlang Bot
June 09, 2015
https://issues.dlang.org/show_bug.cgi?id=10100

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|unspecified                 |D2

--
November 29, 2016
https://issues.dlang.org/show_bug.cgi?id=10100

Ethan Watson <gooberman@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gooberman@gmail.com

--- Comment #1 from Ethan Watson <gooberman@gmail.com> ---
Just hit this myself. Another case of allMembers not returning all members.

--
June 11, 2017
https://issues.dlang.org/show_bug.cgi?id=10100

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw@gdcproject.org

--- Comment #2 from Iain Buclaw <ibuclaw@gdcproject.org> ---
This bug also means you can't pull a list of all gdc builtins at compile time, all to which are prefixed with `__builtin_'.

i.e:
---
import gcc.builtins;
enum builtins = [__traits(allMembers, gcc.builtins)];
pragma(msg, builtins);   // prints ["object"]

--
December 25, 2019
https://issues.dlang.org/show_bug.cgi?id=10100

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |regression

--- Comment #3 from Iain Buclaw <ibuclaw@gdcproject.org> ---
I'd call this a regression.

First bad PR https://github.com/dlang/dmd/pull/2043

--
December 25, 2019
https://issues.dlang.org/show_bug.cgi?id=10100

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
@ibuclaw created dlang/dmd pull request #10697 "fix Issue 10100 - Identifiers with double underscores and allMembers" fixing this issue:

- fix Issue 10100 - Identifiers with double underscores and allMembers

  Convert the identifier whitelist into a blacklist of all possible
  internal D language declarations.

https://github.com/dlang/dmd/pull/10697

--
December 26, 2019
https://issues.dlang.org/show_bug.cgi?id=10100

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #10697 "fix Issue 10100 - Identifiers with double underscores and allMembers" was merged into master:

- 3aa3da224f6e6b075de0ddfb2416c52ee90f049c by Iain Buclaw:
  fix Issue 10100 - Identifiers with double underscores and allMembers

  Convert the identifier whitelist into a blacklist of all possible
  internal D language declarations.

https://github.com/dlang/dmd/pull/10697

--
February 20, 2020
https://issues.dlang.org/show_bug.cgi?id=10100

--- Comment #6 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #10791 "[dmd-cxx] Implement static foreach, aliasing traits, and fix allMembers." was merged into dmd-cxx:

- 2c7947d0507d34e0f72899e9835b88ddf19c31e1 by Iain Buclaw:
  [dmd-cxx] Implement static foreach, aliasing traits, and fix allMembers.

  ----

  Implement DIP 1010 - (Static foreach)

  Support for `static foreach` has been added.

  `static foreach` is a conditional compilation construct that is to `foreach`
what `static if` is to `if`.
  It is a convenient way to generate declarations and statements by iteration.

  ```
  import std.conv: to;

  static foreach(i; 0 .. 10)
  {

      // a `static foreach` body does not introduce a nested scope
      // (similar to `static if`).

      // The following mixin declaration is at module scope:
      mixin(`enum x` ~ to!string(i) ~ ` = i;`); // declares 10 variables x0,
x1, ..., x9
  }

  import std.range: iota;
  // all aggregate types that can be iterated with a standard `foreach`
  // loop are also supported by static foreach:
  static foreach(i; iota(10))
  {
      // we access the declarations generated in the first `static foreach`
      pragma(msg, "x", i, ": ", mixin(`x` ~ to!string(i)));
      static assert(mixin(`x` ~ to!string(i)) == i);
  }

  void main()
  {
      import std.conv: text;
      import std.typecons: tuple;
      import std.algorithm: map;
      import std.stdio: writeln;

      // `static foreach` has both declaration and statement forms
      // (similar to `static if`).

      static foreach(x; iota(3).map!(i => tuple(text("x", i), i)))
      {
          // generates three local variables x0, x1 and x2.
          mixin(text(`int `,x[0],` = x[1];`));

          scope(exit) // this is within the scope of `main`
          {
              writeln(mixin(x[0]));
          }
      }

      writeln(x0," ",x1," ",x2); // first runtime output
  }
  ```

  ----

  Aliases can be created directly from a `__trait`.

  Aliases can be created directly from the traits that return symbol(s) or
tuples.
  This includes `getMember`, `allMembers`, `derivedMembers`, `parent`,
`getOverloads`,
  `getVirtualFunctions`, `getVirtualMethods`, `getUnitTests`, `getAttributes`
and finally `getAliasThis`.
  Previously an `AliasSeq` was necessary in order to alias their return.
  Now the grammar allows to write shorter declarations:

  ```
  struct Foo
  {
      static int a;
  }

  alias oldWay = AliasSeq!(__traits(getMember, Foo, "a"))[0];
  alias newWay = __traits(getMember, Foo, "a");
  ```

  To permit this it was more interesting to include `__trait` in the basic
types
  rather than just changing the alias syntax. So additionally, wherever a type
appears
  a `__trait` can be used, for example in a variable declaration:

  ```
  struct Foo { static struct Bar {} }
  const(__traits(getMember, Foo, "Bar")) fooBar;
  static assert(is(typeof(fooBar) == const(Foo.Bar)));
  ```

  ----

  fix Issue 10100 - Identifiers with double underscores and allMembers

  Convert the identifier whitelist into a blacklist of all possible
  internal D language declarations.

https://github.com/dlang/dmd/pull/10791

--