comparison gen/toir.cpp @ 834:f466f475b654

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.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Tue, 09 Dec 2008 01:56:39 +0100
parents a70ddd449e7d
children 14c3319ac1bb
comparison
equal deleted inserted replaced
833:482cd74d1c71 834:f466f475b654
54 { 54 {
55 Logger::print("VarExp::toElem: %s | %s\n", toChars(), type->toChars()); 55 Logger::print("VarExp::toElem: %s | %s\n", toChars(), type->toChars());
56 LOG_SCOPE; 56 LOG_SCOPE;
57 57
58 assert(var); 58 assert(var);
59
59 if (VarDeclaration* vd = var->isVarDeclaration()) 60 if (VarDeclaration* vd = var->isVarDeclaration())
60 { 61 {
61 Logger::println("VarDeclaration ' %s ' of type ' %s '", vd->toChars(), vd->type->toChars()); 62 Logger::println("VarDeclaration ' %s ' of type ' %s '", vd->toChars(), vd->type->toChars());
63
64 // this is an error! must be accessed with DotVarExp
65 if (var->needThis())
66 {
67 error("need 'this' to access member %s", toChars());
68 fatal();
69 }
62 70
63 // _arguments 71 // _arguments
64 if (vd->ident == Id::_arguments && p->func()->_arguments) 72 if (vd->ident == Id::_arguments && p->func()->_arguments)
65 { 73 {
66 Logger::println("Id::_arguments"); 74 Logger::println("Id::_arguments");
142 } 150 }
143 151
144 LLValue* val; 152 LLValue* val;
145 153
146 if (!vd->ir.isSet() || !(val = vd->ir.getIrValue())) { 154 if (!vd->ir.isSet() || !(val = vd->ir.getIrValue())) {
155 // FIXME: this error is bad!
156 // We should be VERY careful about adding errors in general, as they have
157 // a tendency to "mask" out the underlying problems ...
147 error("variable %s not resolved", vd->toChars()); 158 error("variable %s not resolved", vd->toChars());
148 if (Logger::enabled()) 159 if (Logger::enabled())
149 Logger::cout() << "unresolved variable had type: " << *DtoType(vd->type) << '\n'; 160 Logger::cout() << "unresolved variable had type: " << *DtoType(vd->type) << '\n';
150 fatal(); 161 fatal();
151 } 162 }