| Ticket UUID: | 3075155 | ||
| Title: | oo depends on bytecoding? | ||
| Type: | Bug | Created on: | 2010-09-24 22:03:10 |
| Submitter: | msofer | Assigned to: | msofer |
| Subsystem: | 07. Variables | Severity: | |
| Priority: | 7 High | Last modified: | 2026-10-22 17:19:30 |
| Status: | Closed | Closed by: | serhiy.storchaka |
| Resolution: | Fixed | Closed on: | 2026-10-21 10:03:36 |
| Version: | obsolete: 8.6b1.1 | ||
| Description: | ||||
When I disable the command compiler (juts add '0&&' at the start of the condition in tclCompile.c line 1639), there is a nasty-looking error:
==== oo-27.6 variables declaration - non-interference of levels FAILED
==== Contents of test case:
oo::class create foo {
superclass master
variable x!
constructor {} {set x! 1}
method y {} {incr x!}
}
foo create bar
oo::objdefine bar {
variable y!
method y {} {list [next] [incr y!] [info var] [info local]}
export eval
}
bar y
list [bar y] [lsort [info object vars bar]] [bar eval {info vars *!}]
---- Result was:
{3 2 {} {}} {x! y!} {x! y!}
---- Result should have been (exact matching):
{3 2 y! {}} {x! y!} {x! y!}
==== oo-27.6 FAILED
There is also a segfault in itcl's typeoption.test, which may well be related.
The build is configured as
CFLAGS=-DPURIFY ./configure --disable-shared --enable-symbols
| ||||
| User Comments: | ||||
dkf added on 2010-09-26 00:53:48:
Variable resolver involved! Argh! msofer added on 2010-09-26 19:03:16:
From the chat: [14:56]dkfmiguel: It looks like it's something to do with variable resolvers. I don't pretend to understand those (and have probably got it wrong, I accept) and write code for them by doing the equivalent of throwing rocks at stuff until it seems to work. [14:57]dkfI suspect that the highly restricted resolver used by TclOO is too restricted, but since proc^Wmethod bodies are always compiled I don't care msofer added on 2010-09-26 19:04:51:
After quick look at TclInfoVarsCmd(), it seems that [info vars] is not resolver-aware at all msofer added on 2010-09-26 19:54:51:
This led to discovery of (related, not the same) Bug #3075907. If that one is resolved as an implementation bug, this test is wrong. If it is instead a doc bug, this test is correct. msofer added on 2010-09-27 16:24:05:
The problem seems to be: 1. On a normal build, the presence of y! is detected at compile time by the [incr] compiler. This causes y! to live in the LVT and the resolver to be called at proc loading time. Due to #3075907 y! is reported by [info vars] 2. With command compilers disabled (in this particular case, it is enough to not compile incr), y! is not in the LVT: it will only exist when it is given a value This is all as should be, assuming [info vars] behaved as doc'ed in the man page. Given #3075907 the behaviour depends on the set of commands that are bytecompiled. msofer added on 2010-09-27 17:07:44:
Just replacing [incr] by an equivalent [myIncr] or forcing a non-bc'ed [incr] displays the difference: running the attached script outputs
{3 2 y! {}} {x! y!} {x! y!}
{3 2 {} {}} {x! y!} {x! y!}
{3 2 {} {}} {x! y!} {x! y!}
msofer added on 2010-09-27 17:08:08:
File Added - 387998: show.tcl msofer added on 2010-09-27 22:43:12:
In order for this to work properly if we maintain the current behaviour (ie, if #3075907 is declared a doc bug), we should extend Tcl_ResolverInfo to contain a listProc to be used by [info vars]. This new function would list all variable names that are able to be resolved in the current context. The alternative would probably be unnecessarily expensive: that all OO methods be initialised to contain locals linked to every defined variable, initially undefined. dkf added on 2010-10-20 06:36:04:
Your analysis looks correct. I'll assign it to you (for now) since I'm not going to do any hacking in the guts of resolvers if I can possibly help it. dkf added on 2011-03-11 18:47:07:
I'm not very excited about this after all. Turns out quite a bit of the rest of Tcl also breaks if we disable command compilation. dkf added on 2011-03-11 18:56:06:
It's the interaction of [info variables] with variable resolvers (a feature not used in the rest of the core, hence the bug showing up in TclOO). Having a LVT smooths all that out in this case, but that's hardly ideal. serhiy.storchaka added on 2026-10-21 10:03:36:
Since 8.6.0 ([0b5e337729], bug [2712377]), [info vars] in a method lists the declared object variables itself, so the result no longer depends on bytecompilation. The show.tcl cases give the same result on 8.6 and 9.x. | ||||
