Compile error message not helpful with frameworks

I don’t know if this is new, but I haven’t noticed it before.

If I have a “use framework” in a script and there is a compile error (in this case the handler LocateFiles() is not there) I get a less than helpful compile error message.

use framework "Foundation"
use scripting additions

*** -[BAGenericObjectNoDeleteOSAID LocateFiles]: unrecognized selector sent to object <BAGenericObjectNoDeleteOSAID @0x600003fd5420: OSAID(212) ComponentInstance(0x810025)>

If I remove the “use framework” line the error message is:

«script» doesn’t understand the “LocateFiles” message.

Same result with

use framework "AppKit"

→ Script Debugger 8.0.1 (8A36)
→ Mac OS 11.6 (20G165)

I believe you forgot the current application

Try this…

use framework "Foundation"
use scripting additions

current application's LocateFiles()

These error messages are Apple error messages. Please log a bug with Apple.

(although honestly, in this case I doubt it’s worth the effort.)