Parsing Issue in Debug Mode with Explicit Local Variable

Hi Mark/Shane,

The following code causes a runtime error only in Debug mode (not Standard mode) in Script Debugger (v8.0.10 (8A88) / macOS 15.6 / Intel). Script Editor does not throw any errors.

on run argv
	local argc, arg1
	if argv is me then set argv to {}
	set argc to length of argv
	if argc > 0 then set arg1 to item 1 of argv
	
	return "No error."
end run

The code can be further reduced to the following & still trigger the bug:

local arg1
set argc to 0
if argc > 0 then set arg1 to "Never accessed."
return "No error."

It appears to be an issue with parsing when in Debug mode. I think it’s a regression in a recent version of Script Debugger, since I’ve been using this boilerplate code for years without issue.

Thought I would post this here in case there are any further maintenance updates planned. Otherwise, it can be worked around. Thank you.

We have not changed the local variable parsing in a very long time.

This particular issues is caused by the compound if-then-set construct being used. If you split this up into an if block the problem can be avoided:

If expression then
    set arch to …
end if
2 Likes