Added proper "need 'this' to access member foo" errors instead of "variable foo not resolved" for some cases, added FIXME for the old error!

Added a bit more information to the runtime's cyclic dependency detection exception.
This commit is contained in:
Tomas Lindquist Olsen
2008-12-09 01:56:39 +01:00
parent c8fdab1715
commit b6781a8eae
2 changed files with 17 additions and 5 deletions

View File

@@ -56,10 +56,18 @@ DValue* VarExp::toElem(IRState* p)
LOG_SCOPE;
assert(var);
if (VarDeclaration* vd = var->isVarDeclaration())
{
Logger::println("VarDeclaration ' %s ' of type ' %s '", vd->toChars(), vd->type->toChars());
// this is an error! must be accessed with DotVarExp
if (var->needThis())
{
error("need 'this' to access member %s", toChars());
fatal();
}
// _arguments
if (vd->ident == Id::_arguments && p->func()->_arguments)
{
@@ -144,6 +152,9 @@ DValue* VarExp::toElem(IRState* p)
LLValue* val;
if (!vd->ir.isSet() || !(val = vd->ir.getIrValue())) {
// FIXME: this error is bad!
// We should be VERY careful about adding errors in general, as they have
// a tendency to "mask" out the underlying problems ...
error("variable %s not resolved", vd->toChars());
if (Logger::enabled())
Logger::cout() << "unresolved variable had type: " << *DtoType(vd->type) << '\n';