TCL variables set using "array set" raises undefined variable warning

Hello all,

I am trying to migrate 30K lines of legacy code written with Komodo IDE 8. The original code raised no syntax errors or warnings. But with Komodo IDE 12, I get the following error (I’m sure I’ll find more, but this one is the most common.

	array set baz {a 1 b 2}
	puts $baz(a)

The second line raises a raises a ‘use of undefined variable “baz(a)”’ warning.

(I should note that in v8, even “array unset baz” would have been enough to declare baz to the editor)

Morning @CrashAlpha,

I don’t get any syntax errors appearing in Komodo 12 with the given code. I’d check your prefs to see if you have something set that you’re not aware of.

Edit menu > Preferences > Syntax and Spell checking or … Preferences > Languages > Tcl > Syntax Checking.

I unfortunately know next to nothing about Tcl so I can’t advice on what syntax rule might apply.

It’s also worth checking that Komodo has detected the correct language for the file. That should appear in the file status bar.

Thanks Carey,

I rechecked the syntax prefs - they look correct. I appreciate you don’t need to understand Tcl - it’s very rare - so I will just expand with the following notations

array set baz {a 1 b 2} # declares and initializes array baz
puts $baz(a)            # baz array has been created, no warning should be thrown

This is just to explain that the code is syntactically correct, and why. I could try to fix it myself, but I don’t know where to look to find the linting rules for Tcl. Do you happen to know of any resource for this?

@CrashAlpha,

I wouldn’t jump straight to “Need to fix Komodo”. As I said, I don’t get the same issue as you, which implies to me that there is something up with your dev or Komodo env.

I’d start by restarting Komodo in Safe Mode and attempting to reproduce the issue. You can get into save mode through Help Menu > Troubleshooting > Restart in Safe mode.

If that appears to resolve the issue, I’d shutdown Komodo, find your profile folder, rename your prefs.xml and prefs.xmlc files and start Komodo. If that helps, you know its a config issue in Komodo and you can very likely narrow it down to Syntax Checking for Tcl files.

Also, did you double check that Komodo is detecting the correct file type?

Hi Carey, follow up on this old issue.

Regarding your suggestions above, I tried them all. The problem persists and I have no answer why this worked for you and not for me. I didn’t ask you whether you were using Windows as I am, and this may be an issue if you are not. I will explain.

I found the linter for Tcl under Komodo 12’s folder as:

C:\Program Files (x86)\ActiveState Komodo IDE 12\lib\support\tcl\kotcllint.exe

I ran a test of the Komodo 12 linter linter with a long legacy Tcl file that does not throw any warnings in Komodo 8.6:

kotcllint.exe" -suppress “warnShadowVar warnArgWrite warnNestedExpr warnUndefProc” my_file.tcl

This listed undefined var errors, just as they appear in the Komodo debugger.

I then did exactly the same test, except using C:\Program Files (x86)\ActiveState Komodo IDE 8\lib\support\tcl\kotcllint.exe

(note Komodo 8, not 12)

This threw no errors.

If I understand how the linter works correctly, it operates completely independently of any Komodo settings, so any prefs.xml settings should not apply when running from the command line (i.e. kotcllint.exe is a standalone program, driven only by the command line parameters).

To temporarily solve my problem, I renamed the Komodo 12 kotcllint.exe and copied the Komodo 8 version into the 12 folder to replace it. On the next restart of Komodo IDE 12, my problems disappeared and syntax checking is now correct.

I tried finding the code for kottclint.exe and the best I could find in github was src/lint/koTclLinter.py

However, this doesn’t appear to be doing any syntax checking, in that file there is a dependency on a file I can’t find in the github repository, the PY command is split over lines 174-175:

self.internalLinter = os.path.join(self._supportDir, “tcl”, “komodo_tcl_lint.tcl”)

It seems that some time after the Komodo 8 kotcllint.exe was made (2013-09-06) this bug was introduced, but I am afraid right now I can’t move any further on this to help resolve it for the Komodo Tcl community. AS I hinted previously, if you aren’t also using Windows, perhaps you have version of the linter that doesn’t contain this bug.

Thanks for the help on this!