Menu

#250 uplevel incompatiblity

4.0*
closed-fixed
None
5
2014-03-09
2014-01-27
Don Porter
No

Forwarded from the Tcl ticket tracker.

http://core.tcl.tk/tcl/tktview/d8589a4ec50d0423caa0ee5e0f9603223f08b4e5

When "uplevel" is used to call a method in a different class, it reports that the only available methods are from the calling class, not the target class. In the following example, class A calls a method in class B, which uses "uplevel" to call a method in class A:

if {[package vsatisfies [package require Tcl] 8.6]} {
    package require Itcl 4.0
} else {
    package require Itcl
}
namespace import itcl::*

class A {

    variable b

    constructor {} {
        set b [B #auto]
    }

    public method m1 {} {
        $b m3
    }

    public method m2 {} {
        puts m2
    }
}

class B {

    public method m3 {} {
        uplevel m2 ;# <--------- Fails in Itcl 4.0
    }
}

set a [A #auto]
$a m1

When the above code is run in Tcl8.5.15/Itcl3.4, it correctly displays:

m2

When run in Tcl8.6.1/Itcl4.0b7, it throws an error:

bad option "m2": should be one of...
  b0 cget -option
  b0 configure ?-option? ?value -option value...?
  b0 isa className
  b0 m3

The list of available methods are from class B, not class A. "Uplevel" works correctly with TclOO 1.0.1.

Related

Bugs: #250

Discussion

  • Don Porter

    Don Porter - 2014-02-14

    I'm pleased to see a commit to Itcl trunk
    that claims to fix this, but testing it I
    do not see any change from the incompatible
    behavior originally reported.

     
    • Arnulf Wiedemann

      You are right, I have done accidently the commit, the bug is not fixed
      with the suggested patch. I am on the way to find a correct solution.

      Arnulf

      Am 14.02.2014 17:07, schrieb Don Porter:

      I'm pleased to see a commit to Itcl trunk
      that claims to fix this, but testing it I
      do not see any change from the incompatible
      behavior originally reported.


      [bugs:#250] uplevel incompatiblity

      Status: open
      Created: Mon Jan 27, 2014 06:29 PM UTC by Don Porter
      Last Updated: Mon Jan 27, 2014 06:29 PM UTC
      Owner: nobody

      Forwarded from the Tcl ticket tracker.

      http://core.tcl.tk/tcl/tktview/d8589a4ec50d0423caa0ee5e0f9603223f08b4e5

      When "uplevel" is used to call a method in a different class, it reports that the only available methods are from the calling class, not the target class. In the following example, class A calls a method in class B, which uses "uplevel" to call a method in class A:

       if {[package vsatisfies [package require Tcl] 8.6]} {
           package require Itcl 4.0
       } else {
           package require Itcl
       }
       namespace import itcl::*
      
       class A {
      
           variable b
      
           constructor {} {
               set b [B #auto]
           }
      
           public method m1 {} {
               $b m3
           }
      
           public method m2 {} {
               puts m2
           }
       }
      
       class B {
      
           public method m3 {} {
               uplevel m2 ;# <--------- Fails in Itcl 4.0
           }
       }
      
       set a [A #auto]
       $a m1
      

      When the above code is run in Tcl8.5.15/Itcl3.4, it correctly displays:

       m2
      

      When run in Tcl8.6.1/Itcl4.0b7, it throws an error:

       bad option "m2": should be one of...
         b0 cget -option
         b0 configure ?-option? ?value -option value...?
         b0 isa className
         b0 m3
      

      The list of available methods are from class B, not class A. "Uplevel" works correctly with TclOO 1.0.1.


      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/incrtcl/bugs/250/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #250

  • Arnulf Wiedemann

    • status: open --> closed-fixed
    • assigned_to: Arnulf Wiedemann
     
  • Arnulf Wiedemann

    fix is in trunk and will be in version 4.0.1

     

Log in to post a comment.