www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1073] New: CTFE: mixin expression with a function argument doesn't work

reply d-bugmail puremagic.com writes:

           Summary: CTFE: mixin expression with a function argument doesn't
           Product: D
           Version: 1.009
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: torhu yahoo.com

This code checks if TEST is defined, and defines it if not.  If using the line
that's commented out instead of the one above it, it works as expected.

const int TEST = 1;

char[] def(char[] s) {
    if (!is(typeof(mixin(s))))  // doesn't detect that TEST is defined
    //if (!is(typeof(mixin("TEST"))))  // this works fine
        return "const int " ~ s ~ " = 3;\n";
    else return "";


void main() { }

test.d: variable test.TEST conflicts with test.TEST at test.d(1)

I tried to recreate this problem without CTFE, just with a static if, but it
doesn't happen then.

Mar 20 2007
parent d-bugmail puremagic.com writes:

bugzilla digitalmars.com changed:

           What    |Removed                     |Added
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID

------- Comment #1 from bugzilla digitalmars.com  2007-03-31 17:29 -------
What this code is trying to do is to dynamically change the parse, rather than
the evaluated result, at compile time. This isn't going to work (should use
templates for that). I'll put some clarifications in the spec about this.

Mar 31 2007