.
D 2002-10-31T20:12:08
J assignee msofer
J cmimetype text/plain
J comment This\sis\sperhaps\smuch\smore\sof\san\s[incr\sTcl]\sbug.\s\sI\nsubmitted\sit\s\sin\sthat\sproject\sfirst;\ssee\sbug\s#631735.\s\nHowever,\sI\sthought\sI'd\sraise\sthe\sissue\shere\stoo,\sin\ncase\sit\swas\simportant\sin\ssome\sother\scontext.\s\s(If\snot,\nmy\sapologies.)\n\nThe\sessence\sof\sthe\sissue\sis\sthat\sthe\schange\sin\stclVar.c\nto\smake\sthe\snew\sObjMakeUpvar()\sfunction\scall\nTclLookupSimpleVar(),\swhich\sin\sturn\salways\scalls\sany\nregistered\svariable\sresolver\sfunctions,\smake\sit\svery\ndifficult\s(maybe\simpossible?)\sfor\sthe\s"variable"\ncommand\sto\screate\sa\snew\slocal\svariable\sand\slink\sit\sto\sa\nnamespace\svariable,\sif\sa\sregistered\spackage\slike\s[incr\nTcl]'s\svariable\sresolver\snormally\smakes\sthe\snamespace\nvariable\svisible\sin\sa\slocal\sprocedure\sscope.\n\nWhen\susing\sthe\slatest\s(post-3.2.1)\sCVS\sversion\sof\s[incr\nTcl]\swith\sTcl\s8.4.1,\sthe\s5.6a\stest\sfrom\sthe\sbasic.test\nfile\sfails\sdue\sto\sa\snew,\sdeep\schange\sto\sthe\stclVar.c\nfile.\s\sSpecifically,\sthe\stest\sfails\swith\sthe\smessage\n"can't\supvar\sfrom\svariable\sto\sitself".\n\n(Note\salso\sthat\sthere\sare\stwo\s5.6a\stests;\sthe\sfirst\sone\nis\sthe\sone\sthat\sfails.\s\sIn\sthe\ssuggested\spatch\sbelow,\nthe\ssecond\sone\sis\srenamed\s5.6b.)\n\nA\ssimple\stest\scase\sis\sthe\sfollowing:\n\npackage\srequire\sItcl\nitcl::class\stest_globals\s{\n\s\s\s\s\s\s\s\scommon\sfoo\sgoo\n\s\s\s\s\s\s\s\sproc\sgetval\s{name}\s{\n\s\s\s\s\s\s\s\s\s\s\s\svariable\s$name\n\s\s\s\s\s\s\s\s\s\s\s\sreturn\s[set\s[namespace\stail\s$name]]\n\s\s\s\s\s\s\s\s}\n}\ntest_globals::getval\sfoo\n\nRemoving\sthe\s"variable\s$name"\scommand\scauses\sthis\stest\nto\swork.\n\nA\ssuggested\spatch\sfor\sthe\s[incr\sTcl]\stest\ssuite\sis\nshown\sin\sbug\s#631735.\s\sAfter\ssome\sexamination\sof\sthe\nproblem,\sthis\sseems\sto\sme\sto\sbe\sthe\spreferred\sroute,\nbecause\sI\scan't\ssee\sany\sway\sto\srestore\sthe\sold\nbehaviour\sof\sthe\s"variable"\scommand\swith\s8.4.1\swithout\naltering\sthe\stclVar.c\sfile's\sfunctions\sconsiderably.\n\nThe\sreason\sfor\sthe\sfailure\sis\sthat\sin\stclVar.c,\sthe\nMakeUpvar()\sfunction\shas\sbeen\sreplaced\sin\s8.4.1\swith\nthe\sObjMakeUpvar()\sfunction.\s\sFurther,\sthis\sfunction\sno\nlonger\sduplicates\ssome\scode\sfrom\sTclLookupVar(),\sbut\ninstead,\sboth\sfunctions\snow\suse\sthe\scommon\nTclLookupSimpleVar()\sfunction.\s\sTclLookupSimpleVar()\sis\nalso\sused\sby\sTclObjLookupVar().\n\nThe\sTclLookupSimpleVar()\sfunction\salways\scalls\sthe\nnamespace's\svariable\sresolver(s)\s--\sin\sthis\scase,\nItcl_ClassVarResolver()\sfrom\s[incr\sTcl]'s\sitcl_class.c.\n\sPreviously,\sMakeUpvar()\sdid\snot\scall\sthe\svariable\nresolver(s),\sbut\ssimply\slooked\sfor\slocal\svariables\nusing\ssimilar\scode\sas\sappeared\sin\sTclLookupVar()\s--\nexcept\sfor\sthe\scalls\sto\sthe\svariable\sresolver(s).\n\nThis\sis\simportant\sbecause\sObjMakeUpvar()\s--\spreviously\nMakeUpvar()\s--\sis\scalled\sby\sthe\sTcl_VariableObjCmd()\nfunction\sthat\shandles\sthe\s"variable"\scommand,\sto\screate\na\slink\sbetween\sa\slocal\svariable\sand\sa\snamespace\svariable.\n\nFormerly,\sbecause\sMakeUpvar()\sdid\snot\scall\sthe\nItcl_ClassVarResolver(),\sit\swould\sfind\sno\slocal\nvariable\swhen\shandling\sthe\stest\scase\sshown\sabove,\sand\ncould\sproceed\sto\screate\sa\slocal\svariable\sas\sa\slink\sto\nthe\snamespace\svariable\s"foo",\screated\sby\sthe\s"common"\ncommand.\n\nIn\sTcl\s8.4.1,\sthough,\sObjMakeUpvar()\scalls\sthe\nTclLookupSimpleVar()\sfunction\sto\slocate\sand\screate\sor\nreplace\sthe\slocal\svariable\sthat\sObjMakeUpvar()\swants\sto\nturn\sinto\sa\slink\sto\sthe\snamespace\svariable.\s\sThe\nTclLookupSimpleVar()\sfunction\scalls\sthe\nItcl_ClassVarResolver()\sfunction,\swhich\sof\scourse\sfinds\nno\slocal\svariable\snamed\s"foo"\sand\sproceeds\sto\slocate\nand\sreturn\sthe\snamespace\svariable\snamed\s"foo"\sthat\swas\ncreated\swith\sthe\s"common"\scommand.\n\nObjMakeUpvar()\shas\salso\srecieved\sa\spointer\sto\sthis\ssame\nvariable\sfrom\sTcl_VariableObjCmd(),\swhich\sused\sthe\nTclObjLookupVar()\sfunction\sto\slocate\sthe\snamespace\nvariable\sto\sbe\slinked\sto.\s\sAnd\sTclObjLookupVar()\salso\ncalled\sTclLookupSimpleVar(),\swhich\sin\sturn\scalled\nItcl_ClassVarResolver().\n\nSo\sthe\sObjMakeUpvar()\sfunction\snow\shas\stwo\sidentical\npointers\sfor\sthe\snamespace\sand\slocal\svariables,\sand\nrefuses\sto\stry\sto\smake\sa\slink.\n\nThe\sonly\sway\sI\scan\ssee\sto\sresolve\sthis\sis\sto\salter\sthe\nfunctions\sin\stclVar.c\sto\spass\sdown\ssome\skind\sof\sflag\nthat\swould\sallow\sItcl_ClassVarResolver()\sto\sdetermine\nthis\sspecific\scase.\s\sIt\scan't\srely\son\s!(flags\s&\nTCL_NAMESPACE_ONLY)\sbecause\sthat\smay\sor\smay\snot\sbe\sset\nin\svarious\scombinations,\sdepending\son\sthe\scaller\s--\nspecifically,\sTcl_FindNamespaceVar()\sin\stclNamesp.c\ncalls\s\sthe\svariable\sresolver\sfunction(s)\stoo.\s\sNor\scan\nit\srely\son\svarFramePtr->isProcCallFrame\sbecause\sthat\ndoesn't\sclarify\swhich\schain\sof\sfunctions\sis\scalling\nTclLookupSimpleVar()\sor\sTcl_FindNamespaceVar()\s--\sthese\nare\sthe\stwo\sfunctions\sthat\scan\scall\sthe\svariable\nresolver(s),\sbut\sthey\sare\sin\sturn\scalled\sin\svarious\ncontexts.\n\nWe'd\shave\sto\sspecifically\scatch\sthe\scase\sof\nTcl_VariableObjCmd()\s->\sObjMakeUpvar()\s->\nTclLookupSimpleVar()\s->\sItcl_ClassVarResolver(),\sand\nspecifically\snot\scatch\sthe\scase\sof\sTcl_VariableObjCmd()\n->\sTclObjLookupVar()\s->\sTclLookupSimpleVar()\s->\nItcl_ClassVarResolver().\n\nAll\sof\sthis\sdoes\sraise\sone\sother\ssmall\squestions,\swhich\nis\swhether\sthe\scode\sin\sItcl_ClassVarResolver()\sthat\nlooks\sfor\slocal\svariables,\sand\sis\sduplicated\sfrom\nportions\sof\sthe\sold\sTclLookupVar()\sfunction\s(now\sthat\ncode\shas\sbeen\smoved\sinto\sTclLookupSimpleVar()\sand\naltered),\sshould\sbe\supdated.\s\sFor\sexample,\nTclLookupSimpleVar()\sdoesn't\sperform\sthis\slogic\sif\nTCL_NAMESPACE_ONLY\sis\spassed.\s\sHowever,\swhen\nTcl_FindNamespaceVar()\sis\scalling\nItcl_ClassVarResolver(),\sTCL_NAMESPACE_ONLY\scould\sbe\ntrue\sor\sfalse\s--\sso\sI\sdon't\ssee\san\sobvious\sway\sto\scheck\nit\swithin\sItcl_ClassVarResolver(),\swithout\shaving\ssome\nadditional\scontext\sflags\s--\sa\ssimilar\sissue\sas\sto\sthe\none\sdiscussed\sabove.\n\nWell,\shope\sthat\sall\shelps\ssomeone.\n
J foundin obsolete:\s8.4.1
J priority 5\sMedium
J resolution None
J status Open
J submitter cdarroch
J subsystem 07.\sVariables
J title "variable"\scan't\snot\scall\svar\sresolvers
J type Bug
K 631741ffffffffffffffffffffffffffffffffff
U cdarroch
Z ee2bb256c592684c2a68e4e0e641729b