Skip to content

Commit 28bf928

Browse files
committed
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 <[email protected]>
1 parent c74b6c6 commit 28bf928

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/class.tcl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ proc method {name params body {deleted {}} {del_body {}}} {
9696
set n [lindex $n 0]
9797
if {[regexp -- $n\\M $body]} {
9898
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} {
100101
regsub -all \\\$$n\\M $body "\[set \${this}::$n\]" body
101102
} else {
102103
append decl { ${this}::} $n { } $n

0 commit comments

Comments
 (0)