diff options
author | Steve Bennett <steveb@workware.net.au> | 2021-07-08 22:15:07 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2021-07-08 22:36:50 +1000 |
commit | 500866719dde1cb03d87b550cc8998b31d9e1316 (patch) | |
tree | 32dbb05cdf3318090ff697790c3139ad8dbbbf92 /tests/alias.test | |
parent | 40298deee7cd1e72cb5e34ef98e07bc6adff2573 (diff) | |
download | jimtcl-500866719dde1cb03d87b550cc8998b31d9e1316.zip jimtcl-500866719dde1cb03d87b550cc8998b31d9e1316.tar.gz jimtcl-500866719dde1cb03d87b550cc8998b31d9e1316.tar.bz2 |
collect: correctly handle references as globally scoped names
When a reference is used as a command name (e.g. in oo.tcl) it
is created in the global namespace as ::<reference...
The current check for references that are commands with a reference
count of 1 doesn't take this into account so these references
were not being garbage collected.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'tests/alias.test')
-rw-r--r-- | tests/alias.test | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/alias.test b/tests/alias.test index 00870d1..9ad2dfd 100644 --- a/tests/alias.test +++ b/tests/alias.test @@ -265,4 +265,21 @@ test upcall-1.6 {delete local command with upcall} -body { rename a c } -returnCodes error -result {can't rename local command "a"} +test collect-1.1 {ensure globally scoped references are deleted} { + collect + set result {} + + # Create a globally scoped reference as a function name + set a ::[ref testfunction -] + proc $a {} { return 3 } + lappend result [$a] + # It shouldn't be collected + lappend result [collect] + lappend result [$a] + unset a + # Now it should be collected + lappend result [collect] + set result +} {3 0 3 1} + testreport |