OK, thanks for sharing. So this is something the KM is doing, not something that the Finder is doing. Peter has already said he will fix it in the next update.
I don't know how KM works, but in my case and with this macro there is nothing in my Trash can.
Correct.
I am somewhat surprised this issue has not come up before, but that's the way it is.
Anyway, thank you @peternlewis and @gglick for your feedback.
Do you habitually empty your trash? Or is it on a remote volume without a trash.
Before saving the file, Keyboard Maestro determines if the existing file is a package or folder and if so asks the system to trash it (it cannot simply refuse in this case, since some file types are packages or folders, and so it may be completely correct to replace a package or folder).
The folder is trashed and a file is written in its place with the same name.
The folder is not "converted in to a file" (which would be impossible in any event).

Do you habitually empty your trash?
Yes, I do, but it so happens I haven't emptied it since I ran the macro.

Or is it on a remote volume without a trash.
All my files are on a VeraCrypt volume, but when I delete something from there it goes to the OS trash can.

The folder is trashed and a file is written in its place with the same name.
That's what happened, but those files were empty. In fact, I still have them in the Trash.

That's what happened, but those files were empty. In fact, I still have them in the Trash.
Yes, the original folder would have been trashed, and an empty file would be written in its place.