tsp icon indicating copy to clipboard operation
tsp copied to clipboard

unable to handle global variables accesses using double-colon syntax

Open bovine opened this issue 9 years ago • 0 comments

tsp seems to reject setting or accessing global variables when they are referenced using the double-colon (global namespace) syntax. If they are accessed by declaring them with the "global" command within the proc, then it seems to allow that.

#!/usr/local/bin/tclsh8.6

package require tsp

set moo "cow"

tsp::proc doit1 {} {
    #tsp::procdef void
    #tsp::compile assert
    set ::moo "bull"
}

tsp::proc doit2 {} {
    #tsp::procdef void
    #tsp::compile assert
    global moo
    set moo "steer"
}

doit1
doit2

Result of running it:

$ ./tspglobal.tcl
compile type: assert, proc doit1, but resulted in errors:
4: set arg 1 previously undefined variable not a valid identifer: "::moo"
    while executing
"error "compile type: $compileType, proc $name, but resulted in errors:\n[join $errors \n]""
    (procedure "::tsp::compile_proc" line 53)
    invoked from within
"::tsp::compile_proc $scriptfile $name $argList $body"
    (procedure "tsp::proc" line 6)
    invoked from within
"tsp::proc doit1 {} {
    #tsp::procdef void
    #tsp::compile assert
    set ::moo "bull"
}"
    (file "./tspglobal.tcl" line 7)

bovine avatar Aug 07 '15 15:08 bovine