Skip to content
Tcl Source Code View Ticket
Login

View Ticket

empty named array misbehavior

Closed / Invalid217845ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:44:47
OriginalBugID: 1778 Bug
Version: 8.1b3
SubmitDate: '1999-04-09'
LastModified: '1999-08-07'
Severity: LOW
Status: Closed
Submitter: pat
ChangedBy: hobbs
RelatedBugIDs: 2294 915
OS: Linux-Red Hat
Machine: Other
FixedDate: '2000-10-25'
ClosedDate: '1999-08-07'


Name:

Jean-Luc Fontaine



Extensions:

stooop-3.7, scwoop-2.6, tkTable-2.4, BLT-2.4h, tkpiechart-5.3



CustomShell:

just the patch above



ReproducibleScript:

namespace a {

        variable {}

    }

    set a::(x) 0

    puts $a::(x)  ;# works with current tcl version

    namespace a {

        set (x) 0

        puts $(x) ;# should work as line above

    }



ObservedBehavior:

see script above



DesiredBehavior:

see script above



Patch:

*** generic/tclParse.c.origFri Apr  9 22:00:23 1999

--- generic/tclParse.cFri Apr  9 22:03:39 1999

***************

*** 1583,1588 ****

--- 1583,1589 ----

      unsigned char c;

      int varIndex, offset;

      Tcl_UniChar ch;

+     unsigned array;

  

      if (numBytes >= 0) {

  end = string + numBytes;

***************

*** 1687,1698 ****

      }

      break;

  }

  tokenPtr->size = src - tokenPtr->start;

! if (tokenPtr->size == 0) {

      goto justADollarSign;

  }

  parsePtr->numTokens++;

! if ((src != end) && (*src == '(')) {

      /*

       * This is a reference to an array element.  Call

       * ParseTokens recursively to parse the element name,

--- 1688,1700 ----

      }

      break;

  }

+ array = ((src != end) && (*src == '('));

  tokenPtr->size = src - tokenPtr->start;

! if ((tokenPtr->size == 0) && !array) {

      goto justADollarSign;

  }

  parsePtr->numTokens++;

! if (array) {

      /*

       * This is a reference to an array element.  Call

       * ParseTokens recursively to parse the element name,

*** tests/encoding.test.origFri Apr  9 22:10:54 1999

--- tests/encoding.testFri Apr  9 22:11:39 1999

***************

*** 262,268 ****

  

  test encoding-13.1 {LoadEscapeTable} {

      set x [encoding convertto iso2022 ab\u4e4e\u68d9g]

! } "\x1b(Bab\x1b$@8C\x1b$(DD%\x1b(Bg"

  

  test encoding-14.1 {BinaryProc} {

      encoding convertto identity \x12\x34\x56\xff\x69

--- 262,268 ----

  

  test encoding-13.1 {LoadEscapeTable} {

      set x [encoding convertto iso2022 ab\u4e4e\u68d9g]

! } "\x1b(Bab\x1b$@8C\x1b\$(DD%\x1b(Bg"

  

  test encoding-14.1 {BinaryProc} {

      encoding convertto identity \x12\x34\x56\xff\x69

*** tests/parseOld.test.origFri Apr  9 22:11:53 1999

--- tests/parseOld.testFri Apr  9 22:12:40 1999

***************

*** 185,193 ****

      set b

  } {a$!}

  test parseOld-5.12 {array variable substitution} {

!     set b a$()

!     set b

! } {a$()}

  catch {unset a}

  test parseOld-5.13 {array variable substitution} {

      catch {unset a}

--- 185,192 ----

      set b

  } {a$!}

  test parseOld-5.12 {array variable substitution} {

!     list [catch {set b a$()} msg] $msg

! } {1 {can't read "()": no such variable}}

  catch {unset a}

  test parseOld-5.13 {array variable substitution} {

      catch {unset a}



PatchFiles:

generic/tclParse.c

    tests/encoding.test

    tests/parseOld.test
welch Closed ticket [217845ffff]. [History diff]2000-10-26 07:59:47
dgp Ticket [217845ffff]: 3 changes [History diff]2001-04-13 23:20:42
Log in (anonymous is fine) to add a comment.