Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Ticket #133 (new defect)

Opened 11 years ago

Last modified 11 years ago

error after a mixin statment

Reported by: redsea Assigned to:
Priority: major Component: descent.core
Version: 0.5 Keywords:
Cc:

Description

I use mixin to control some alias define, for example, if "test" module's dbg is on, then mixin would alias "od" to "syncprint", otherwise alias it to "nullprint".

in this case, first 4 statment in a module is like the following:

module test;

private import prjcfg;

private const char [] mod="test";
mixin (dbgctrl);

20080501 version works ok, but 20081008 would think the rest codes after the mixin is not D code.

sample code:

module test;

private import prjcfg;

private const char [] mod="test";
mixin (dbgctrl);


import xlib.comm.session;

//import xlib.comm.selector.parts;

import xlib.comm.selector.simple;


import xlib.comm.evsrc.tcpsock;
import xlib.comm.evsrc.udpsock;

dbgctrl is:

const char [] dbgctrl=
"
struct dbg
{
    mixin (getvalue_stmt(mod, \"dbg\",        true,  true));
    mixin (getvalue_stmt(mod, \"od\",         true,  true));

    mixin (getvalue_stmt(mod, \"ut\",         dbg,   dbg));
    mixin (getvalue_stmt(mod, \"uttitle\",    ut,    ut));

    mixin (getvalue_stmt(mod, \"trace\",      dbg,   false));
    mixin (getvalue_stmt(mod, \"ot\",         trace, false));

    mixin (getvalue_stmt(mod, \"trace_dtor\", true,  false));
    mixin (getvalue_stmt(mod, \"trace_fail\", true,  true));
};


// alias od
static if (dbg.od || dbg.trace_dtor)
    alias xlib.tools.applog.syncOut    od;
else
    alias xlib.tools.applog.nullPrint  od;

// alias unit test's title
static if (dbg.uttitle)
    alias xlib.tools.applog.syncOut    title;
else
    alias xlib.tools.applog.nullPrint  title;

// alias ot (for trace)
static if (dbg.trace)
{
    alias xlib.tools.applog.syncOut    ot;

}
else
{
    alias xlib.tools.applog.nullPrint  ot;
}
";

Change History

10/20/08 00:01:43 changed by asterite

  • owner changed.
  • version set to 0.5.
  • component changed from descent.astview to descent.core.

Hi redsea,

I don't understand what is the error you are getting. I copied the code and it worked fine. Do you mean you get a semantic error? In which position? Or are you getting a popup saying some error happened?

Is that D1 or D2?

Thanks!