Bug 4732 – __traits(identifier) performs constant folding on symbols

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-08-26T12:13:00Z
Last change time
2011-02-06T13:44:49Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
rsinfu

Attachments

IDFilenameSummaryContent-TypeSize
741traits-identifier.patchPatch against dmd r621text/plain1001

Comments

Comment #0 by rsinfu — 2010-08-26T12:13:50Z
Created attachment 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
Comment #1 by clugdbug — 2011-02-06T13:44:49Z