"read POSIX file" breaking when I "use framework "Foundation""

I have a library handler that read a text file generated by another script. It stores an Applescript record in the test file for information passing between scripts. It reads the file in with the line:

set existingRecord to read POSIX file recordLocation as record

Which has been working fine for years…

then today I add a new, unrelated handler that contains some ASObjC code, so at the top of the library, I add:

use framework "Foundation"

Now when the handler gets to the line:

set existingRecord to read POSIX file recordLocation as record

It errors:

Apparently there’s some terminology conflict there, where it’s attempting to evaluate my Applescript code as ASObjC code, and it’s failing? But I don’t understand why. Can someone please explain why it’s failing, and also how I fix it?

Thanks.

The issue is discussed here:

https://latenightsw.com/adding-applescriptobjc-to-existing-scripts/

Although that refers to using file, the issue also affects POSIX file.

So:

set existingRecord to read (recordLocation as POSIX file) as record

Thank you Shane, very helpful, great link.

Still, this is highly unintuitive behavior on Apple’s part.

I suspect it’s entirely unintentional, but something to do with the fact that both furl and old-style file references compile to the term file.