[Issue 4732] New: __traits(identifier) performs constant folding on symbols

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Aug 26 12:13:59 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4732

           Summary: __traits(identifier) performs constant folding on
                    symbols
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: patch, rejects-valid
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: rsinfu at gmail.com


--- Comment #0 from Shin Fujishiro <rsinfu at gmail.com> 2010-08-26 12:13:50 PDT ---
Created an attachment (id=741)
Patch against dmd r621

__traits(identifier) tries to fold its argument to a constant. And symbols of
manifest constants cannot be obtained via the traits:
-------------------- test.d
enum symbol = 42;
pragma(msg, __traits(identifier, symbol), " = ", symbol);
--------------------
% dmd -c -o- test
test.d(2): Error: argument 42 has no identifier
false = 42
--------------------

For the 'identifier' traits, folding an argument to a constant does not make
sense. The proposed patch fixes the problem by disabling constfold on arguments
as done in the 'isSame' traits.

With the patch, the result gets corrected:

% dmd-patched -c -o- test
symbol = 42

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list