Index: generic/nsf.c =================================================================== diff -u -r433dab40ed472f0bcddf9c2afd176e3a2ff4de0b -r41e9eeaee026cfb812202269fa27f623d4ec67e1 --- generic/nsf.c (.../nsf.c) (revision 433dab40ed472f0bcddf9c2afd176e3a2ff4de0b) +++ generic/nsf.c (.../nsf.c) (revision 41e9eeaee026cfb812202269fa27f623d4ec67e1) @@ -2529,15 +2529,23 @@ */ varName ++; - /* We have an object and create the variable if not found */ + /* + * We have an object and create the variable if not found + */ assert(object); - varTablePtr = object->nsPtr ? Tcl_Namespace_varTablePtr(object->nsPtr) : object->varTablePtr; -#if 0 - if (varTablePtr == NULL) { - /* this seems to be the first access to object->varTablePtr for this object */ - object->varTablePtr = varTablePtr = VarHashTableCreate(); + if (object->nsPtr) { + varTablePtr = Tcl_Namespace_varTablePtr(object->nsPtr); + } else if (object->varTablePtr) { + varTablePtr = object->varTablePtr; + } else { + /* + * In most situations, we have a varTablePtr through the clauses + * above. However, if someone redefines e.g. the method + * "configure" or "objectparameter", we might find an object with + * an still empty varTable, since these are lazy initiated. + */ + varTablePtr = object->varTablePtr = VarHashTableCreate(); } -#endif assert(varTablePtr); /*fprintf(stderr, "Object Var Resolver, name=%s, obj %p, nsPtr %p, varTablePtr %p\n", Index: tests/varresolution.test =================================================================== diff -u -r3696772f6383ca87f6f4c7716a12843afacdff2f -r41e9eeaee026cfb812202269fa27f623d4ec67e1 --- tests/varresolution.test (.../varresolution.test) (revision 3696772f6383ca87f6f4c7716a12843afacdff2f) +++ tests/varresolution.test (.../varresolution.test) (revision 41e9eeaee026cfb812202269fa27f623d4ec67e1) @@ -1102,3 +1102,14 @@ } } +Test case unconfigured-varresolver { + # + # Test robustness of varresolver for unconfigured objects + # + Class create O { + :public method configure args {;} + :create ateh + } + ? {ateh eval {info exists :x}} 0 +} +