@matheusbsbs / matheus-bagliano / commits / 28bf928cf8
Fork 0

git-gui: Don't attempt to inline array reads in methods

If a variable reference to a field is to an array, and it is the only reference to that field in that method we cannot make it an inlined [set foo] call as the regexp was converting the Tcl code wrong. We were producing "[set foo](x)" for "$foo(x)", and that isn't valid Tcl when foo is an array. So we just punt if the only occurance has a ( after it. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed May 8, 2007 at 21:31 UTC 28bf928cf81eec720bc8a31179a0c9cf688d5af3
1 file changed +2 -1
lib/class.tcl
+2 -1
@@ -96,7 +96,8 @@ proc method {name params body {deleted {}} {del_body {}}} {
96 set n [lindex $n 0]
97 if {[regexp -- $n\\M $body]} {
98 if { [regexp -all -- $n\\M $body] == 1
99 - && [regexp -all -- \\\$$n\\M $body] == 1} {
99 + && [regexp -all -- \\\$$n\\M $body] == 1
100 + && [regexp -all -- \\\$$n\\( $body] == 0} {
101 regsub -all \\\$$n\\M $body "\[set \${this}::$n\]" body
102 } else {
103 append decl { ${this}::} $n { } $n