What's wrong with this alias?

Dr.No jckj33 at gmail.com
Thu Apr 26 17:56:22 UTC 2018


consider this:

module report;

// output an error message on stderr
void error(A...)(string fmt, A args)
{
	import colorize : fg, color, cwriteln, cwritefln, cwrite;
	stderr.cwrite("error: ".color(fg.yellow));
	cwritefln(fmt.color(fg.yellow), args);
}

void warning(A...)(string fmt, A args)
{
	import colorize : fg, color, cwriteln, cwritefln, cwrite;
	cwrite("warning: ".color(fg.blue));
	cwritefln(fmt.color(fg.blue), args);
}

then

class C
{

	void error(A...)(string fmt, A args)
	{
		import report : error;
		reportedAnyError = true;
		error(fmt, args);
	}
	alias warning = report.warning;
}


I got this:

Error: undefined identifier report.warning

but this works:

	void warning(A...)(string fmt, A args)
	{
		import report : warning;
		warning(fmt, args);
	}

why alias cannot find my symbol there?



More information about the Digitalmars-d-learn mailing list