Inside a Finder tell statement, the term folder is indeed a class. You would need to use the statement outside the tell statement, or use something from the Finder itself such as the kind property, for example:
set myVariable to (kind of (directory as alias) is "Folder")
Note that kind can differ from info for, since bundles/packages such as applications are technically also folders.
The privilege violation is from using the info for command (a long deprecated StandardAdditions command) in a Finder tell statement. There are a few that don't trigger the warning, such as display dialog, but common practice is to only use statements inside an application tell statement that specifically target that application. The terms my or of me can be used for statements that target something else (handlers, etc), but this case is problematic in that the result from info for actually uses scripting terms for the record keys.
Topic:
App & System Services
SubTopic:
Automation & Scripting
Tags: