Itcl - the [incr Tcl] extension

View Ticket
Login
Ticket Hash: c45384364cc29a5796ffc7698a4c61697a13f728
Title: 'this' resolution misbehaves in [uplevel]led evaluation
Status: Closed Type: Code_Defect
Severity: Important Priority: Immediate
Subsystem: Resolution: Fixed
Last Modified: 2017-05-16 14:39:59
Version Found In: 4.0.5
User Comments:
dgp added on 2017-05-09 13:53:58:
Demonstration script:

puts "Tcl  version : [package present Tcl]"
puts "Itcl version : [package require Itcl]"

itcl::class M {
  variable foo M
  method eval script {uplevel 1 $script}
}
M m

itcl::class C {
  variable foo C
  method demo {varName} {
    set script [subst -nocommands {
        puts [namespace which -variable $varName]
        puts "FOO is [set $varName]\n"
    }]
    uplevel 1 $script
    uplevel 1 [list m eval $script]
  }
}
C c

itcl::class D {
  variable foo D
  method demo {} {
    c demo foo
    puts [namespace which -variable foo]\n
    c demo this
    puts [namespace which -variable this]
  }
}
D d
d demo 

Results from Itcl 3.4.3:

Tcl  version : 8.6.7
Itcl version : 3.4

FOO is D


FOO is D




FOO is ::d


FOO is ::d



Results from Itcl 4.0.6:

Tcl  version : 8.6.7
Itcl version : 4.0.6
::itcl::internal::variables::oo::Obj18::D::foo
FOO is D

::itcl::internal::variables::oo::Obj18::D::foo
FOO is D

::itcl::internal::variables::oo::Obj18::D::foo

::itcl::internal::variables::oo::Obj16::C::this
FOO is ::c

::itcl::internal::variables::oo::Obj14::M::this
FOO is ::m

::itcl::internal::variables::oo::Obj18::D::this

dgp added on 2017-05-12 14:36:22:
The feature branch dgp-method-type does not
suffer from this bug.  

The same failed Itcl Stack design that prevents
proper NRE-enabling is also causing this failure.

dgp added on 2017-05-12 16:49:13:
It appears this is a revisit of the issues ironed
out two years ago in the branch dgp-frame-context.

dgp added on 2017-05-12 16:53:32:
Confirmed that the tip of the dgp-frame-context branch
is a fix for this.

dgp added on 2017-05-16 14:39:59:
Fixed by merging dgp-method-type and declaring
the result to be Itcl 4.1.0.

Update to Itcl 4.1.0 when released to fix this issue.