Tcl Source Code

Ticket Change Details
Login
Overview

Artifact ID: b3f958f3399f5311104214c54d046a7a0671c061
Ticket: a122627849570b9175e6a2359560d1204733a854
procedure 'parray' doesn't check for an array
User & Date: anonymous 2013-11-22 13:45:46
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/html"
  4. comment changed to:
    There's a bug in the built-in 'parray' procedure of Tcl 8.4.
    <br />
    The 'parray' procedure check if the variable is an array, and if it is not, then it tries to print it's content instead of it's name.
    
     
    
    Code example:
    <pre>
    proc array_to_list {arr_VarName} {
                    upvar $arr_VarName arr
                    if [array exists arr] {
                                    set tmp [array get arr]
                                    parray arr
                                    unset arr
                                    parray arr
                                    array set arr [array get tmp]
                                    return 1
                    }
                    return 0
    }
    
    set b(a) "5"
    set b(c) "asdas"
    set b(dd) "al94i"
    
    if [array_to_list b] {
                    puts $b
    } else {
                    puts "BAAAAAAA"
    }
    </pre>
    
    Output example:
    <pre>
    arr(a)  = 5
    arr(c)  = asdas
    arr(dd) = al94i
    
    "arr" isn't an array
        while executing
    "error "\"$a\" isn't an array""
        (procedure "parray" line 4)
        invoked from within
    "parray arr"
        invoked from within
    "if [array exists arr] {
                                    set tmp [array get arr]
                                    parray arr
                                    unset arr
                                    parray arr
                                    array set arr [array get tmp]
                                    return 1
                    }"
        (procedure "array_to_list" line 3)
        invoked from within
    "array_to_list b"
        invoked from within
    "if [array_to_list b] {
                    puts $b
    } else {
                    puts "BAAAAAAA"
    }"
        (file ".\test.tcl" line 22)
    </pre>
    
    The line "error "\"$a\" isn't an array"" has the error, which is relevant to the second 'parray arr' line that is in the 'array_to_list' procedure.
    <br />
    ActiveState ActiveTcl <br />8.4.20.0.297203                                              Jun 05, 2013
    
  5. foundin changed to: "8.4"
  6. is_private changed to: "0"
  7. login: "anonymous"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "5d6a65d81064024e292e94471bcec5cccc966f90"
  10. resolution changed to: "None"
  11. severity changed to: "Minor"
  12. status changed to: "Open"
  13. submitter changed to: "anonymous"
  14. subsystem changed to: "- New Builtin Commands"
  15. title changed to: "procedure 'parray' doesn't check for an array"
  16. type changed to: "Bug"