Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2016-03-17
12:24 • Closed ticket [1a25fdfec6]: IndexTailVarIfKnown makes pointless call plus 7 ... artifact: 4452a764d2 user: dgp
12:24
[1a25fdfec6] Enable compile of commands like [variable ${ns}::v]. check-in: 9b6183cdf5 user: dgp tags: core-8-6-branch
2016-03-11
15:42 • Ticket [1a25fdfec6] IndexTailVarIfKnown makes pointless call status still Op... artifact: 14552c23f4 user: dgp
14:30 • Ticket [1a25fdfec6]: 4 changes artifact: 6736a4a435 user: dgp
14:25 • New ticket [1a25fdfec6]. artifact: 15a3530d9a user: dgp

IndexTailVarIfKnown makes pointless call

Closed / Fixed1a25fdfec6ecf9064dcd6337d00db87028a96188Created 11 years agoUpdated 11 years ago
Descriptionplain2016-03-11 14:25:13
In tclCompCmdsGR.c the routine IndexTailVarIfKnown()
misuses TclWordKnownAtCompileTime().

The overall routine is examining the word 
parsed in varTokenPtr, and wants to report whether
the tail portion of that word can be determined
so the local varname can be known, and bytecode
can be generated for commands like [global] and [variable].

In particular it appears to want to support bytecoding
of things like

    variable [find-namesapce]::foo

where the whole value of the argument is not known
until runtime, but we know the tail portion now, so
we know the local name argument to INST_NSUPVAR.

The problem is the routine TclWordKnownAtCompileTime()
is called to ask whether the final portion of the
argument word (the 'last token') is known.  This use
misses the fact that TWKACT is explicitly the routine
Tcl***WORD***KnownAtCompileTime() and will only return
true for an entire word, not for tail portions of a word.
This call always returns false as written.  All the code
written to handle a true return is unused and worthless.

The idea here seems worthwhile, so the fix may be to just
put the needed testing here directly, replacing the misused
TWKACT call.
Referenced by1
dgpplain2016-03-11 14:30:28
This error appears to have been in the original code.

http://core.tcl.tk/tcl/info/8fe01ff44102e6ba
dgpplain2016-03-11 15:42:31
Candidate for merge to 8.6, etc.:

http://core.tcl.tk/tcl/info/2334f398b81654e9
dgpplain2016-03-17 12:24:38
Fixed for 8.6.6+.
Log in (anonymous is fine) to add a comment.