Snow Leopard bug when addressing null args to explicit run handler

The following code will work only in Applescript Editor on Snow Leopard (10.6. less-than 3)


on run argList
    if class of argList is script then -- user provided nothing
        display dialog "no args passed" -- replace with more useful code
    else
        display dialog "args were passed"  -- maybe process those args
    end if
end run

The bug appears when it’s run as a script application (test was as bundle), complaining that it “couldn’t get class.”

The workaround is to wrap the initial reference to argList in an error trap. e.g.,


on run argList
    try
         class of argList -- user provided nothing
    on error -- user provided argument list
         ""
    end try
    if (result as string) is "script" then -- user provided nothing
        display dialog "no args passed" -- replace with more useful code
    else
        display dialog "args were passed"  -- maybe process those args
    end if
end run