Menu

#17 Bug: Unknown variable - array variables, relative namespace location

1.0
accepted
None
Bug
2019-03-18
2019-03-18
Pizarro
No

There appears to be a false positive being identified, for array variables that are being accessed via relative namespace paths.

If the variable is not an "array", there is no false positive.

Example code that illustrates the issue:

namespace eval ::a {
     namespace eval b {
       # declare/set variables
      array set c [list]
      variable d
      set e ""
    }

    proc testVars {} {
      # absolute namespace - identified as OK
      puts [array names ::a::b::c]
      # relative namespace - identified as problem
      puts [array names b::c]

      # basic stuff identified as OK
      puts $b::c
      puts $b::d
      puts $b::e
    }
  }
  a::testVars 

  # This is identified as OK
  puts [array names ::a::b::c]
  # This is not identified as OK
  puts [array names a::b::c]

  # These are OK
  puts $::a::b::d
  puts $a::b::d

Discussion

  • Peter Spjuth

    Peter Spjuth - 2019-03-18
    • status: open --> accepted
    • assigned_to: Peter Spjuth
     
  • Peter Spjuth

    Peter Spjuth - 2019-03-18

    I do not think it is array per se, but checks done by syntax token "v", which "array names" uses.
    The checks should bail out for complex cases like this and just be quiet.

     

Log in to post a comment.

MongoDB Logo MongoDB