variable name resolution broken
Closed / Postponed736729ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 23 years ago
Descriptionplain2003-05-12 22:48:05
Name resolution is slightly broken in 8.4. % set x 1 1 % unset x % namespace eval test set x 0 0 % set x 0 Note that the temporary fix of [Bug 735335] solves this issue - for 8.4.3 and in HEAD: the result is as it should be: can't read "x": no such variable
msoferplain2003-05-13 06:06:44
Logged In: YES user_id=148712 I have not managed to devise a test for this yet; the error seems to depend on some subtle interplay with the literal mechanism. It is triggered at the tclsh prompt, but apparently not in a sourced file (pure string evaluation) or a proc body (pure compilation).
dgp Ticket [736729ffff]: 1 change
[History diff]2003-05-14 21:12:21
dgp Ticket [736729ffff]: 1 change
[History diff]2003-06-28 02:15:27
msoferplain2004-03-27 11:10:58
Logged In: YES user_id=148712 Weird stuff - something to do with literals? If we replace the variable name 'x' by 'y', there is no bug!!!
msoferplain2004-05-22 10:43:16
Logged In: YES user_id=148712 Bug 735335 isnow fixed, but this one still lives ...
msoferplain2004-05-22 16:36:13
Logged In: YES user_id=148712 Thebug is not in the obj type, but rather in the lookup mechanism. The bug is still present in HEAD with the temporary fix; a script that exposes it is % namespace eval a upvar x q % namespace eval b set x 0 0 % set x 0 What is happening in the original script is: - x is a shared literal (created by init.tcl) - 'set x 1; unset x' shimmers x to tclNsVarNameType - the shared literal keeps an (undefined) variable x in the global hashtable - the lookup mechanism finds the variable in the hashtable, and uses it In this new version, x is kept in the hashtable by upvar instead.
msoferplain2004-05-22 16:42:51
Logged In: YES user_id=148712 The bug is present since bog knows when - at least 8.3.4 shows the buggy behaviour in the upvar version below ...
msoferplain2004-05-22 22:29:30
Logged In: YES
user_id=148712
More fun with zombie variables - ie, those that have an
entry in the hashtable but (flags & VAR_UNDEFINED) is true:
% namespace eval a {}
% upvar 0 a::q x
% namespace eval a {set x 1; set q}
1
% set x
1
% set a::x
can't read "a::x": no such variable
msoferplain2004-05-24 03:11:07
Logged In: YES user_id=148712 Closing this bug ticket - the bug introduced in tcl8.4 is fixed, 8.4 and 8.5 behave now the same as all previous 8.x (AFAICT). Opening [Bug 959052] for the remaining issues.
msoferplain2004-05-26 02:48:46
Logged In: YES user_id=148712 Cached ns varnames still interfere with name resolution: A cached varName may keep a variable's name in the namespace's hash table, which is the resolver's criterion for existence (see test namespace-17.10). This caching now disabled, will have to wait until the variable name resolution is fixed.
Log in (anonymous is fine) to add a comment.