You’re seeing AppleScript in action. When the
if exists... line is called, AppleScript’s
result is first set to the NSURL of
targetFile in the firstLine of the handler it calls:
on exists object aFileOrPath set aURL to my makeURLFromFileOrPath:aFileOrPath return (aURL's checkResourceIsReachableAndReturnError:(missing value)) as boolean end exists object
Because the handler is called as part of an
if statement, which do not return results, AppleScript’s
result property remains unchanged, despite the actual result of the handler call being a boolean value.
This sort of thing can happen if either the
return statement of a handler is followed by code rather than a variable as above, or where the handler has no
return statement and its last line is code.
I’d take some convincing that it needs attending to. I could go through every handler and add an extra
return line, but I’m not sure there’s any public benefit. I consider exposing quirks as educational