www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18569] New: std.traits.moduleName problem with enum

https://issues.dlang.org/show_bug.cgi?id=18569

          Issue ID: 18569
           Summary: std.traits.moduleName problem with enum
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: minor
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: claudemr live.fr

How to reproduce the issue, 2 files containing the same code, only the module
name changes.

aa.d:

module aa;
import std.traits : moduleName;
private enum stuff = 0;
pragma(msg, moduleName!stuff);

bb.d:

module bb;
import std.traits : moduleName;
private enum stuff = 0;
pragma(msg, moduleName!stuff);

Command line:
dmd aa.d bb.d -main

Output of the command line:
aa
aa

Whereas I would expect:
aa
bb

-------------

Replacing:
 private enum stuff = 0;
with:
 private int stuff = 0;
gives a proper result.

Replacing:
 private struct stuff { };
with:
 private struct stuff { };
also gives a proper result.

It does not look like it comes from the "parent" traits, as using:
 private enum stuff = 0;
 pragma(msg, __traits(parent, stuff).stringof[7..$]);
also gives a proper result.

--
Mar 07 2018