package require Itcl
itcl::class Dog {
method bark {}
}
itcl::body Dog::bark {} {
variable bite
}
Dog fido
fido bark
can't upvar from variable to itself
while executing
"variable bite"
(object "::fido" method "::Dog::bark" body line 2)
invoked from within
"fido bark"
Itcl's custom namespace var resolver intervention on "bite"
is producing something the Tcl core cannot deal with
as intended, I think.
I think the essence of the problem is that the Tcl
core calls TclObjLookupVarEx() with the flag
TCL_NAMESPACE_ONLY but the Itcl namespace
var resolver steps in and sends back a reference
to a proc-local variable.
I tried the example with tcl 8.6 trunk and itcl 4.0b7 trunk and I do not get the error show above. What is different in my environment?
You do not have an Itcl 3.4 getting brought in
by mistake. :)
This is a bug in only Itcl 3.4. Itcl 4 doesn't
suffer the problem.
Replacing the body with
set variable variable
$variable bite
makes things work.
This is a bug in the [variable] compiler.
Um "makes things work" may be an exaggeration.
Avoids the same error message.
Arranging for AVOID_RESOLVERS to get added
to the flags in the INST_VARIABLE implementation
makes the error go away. No confidence at all
that this is an actual solution.
Fixed for Itcl 3.4.2 release.
Diff: