I'm writing a non-trivial class that holds a collection of key-value pairs and during compilation I receive a very strange error that I cannot figure out. In a function, extremely similar to this function here, but without the context due to the complexity of the code needed, I receive the error:
TValue& operator[](const TKey& key) {
TDict::Node* node = mData.Begin(); // ERROR: 'node' was not declared in this scope
// -_- ... really?
do {
if(node->Data.Key == key) {
return node->Data.Value;
}
} while(node != mData.End());
this->Add(key, TValue());
return this->End()->Data.Value;
}
- TDict is a typedef that expands into
List<KeyValuePair<TKey, TValue> >
- TDict::Node is visible during the compilation process.
- No other variable is called node, obviously.
- This is a member function.
I am not asking for the code needed to correct this, but rather a synopsis of potential situations where an error like this can occur.