If the function for creating that object has the NOCOMBAT restriction, then you will not have that object to pass it.
If you think creating a target without player input is possible, then you're wrong. Creating a target object would require a function which is restricted from combat use. OnHover and OnClick events
do require player input, and are therefore not restricted from in-combat use.
Moreover, WOW has protected classes and 'tainting', which makes your example of LUA comparisons moot, because action calls refuse to run if scripts are ran or it receives any data from a tainted source. It is for this reason that HealBot does not have conditional statements in it, such as canceling a heal action of the target's HP is too low/high.
http://www.wowwiki.com/Secure_Execution_and_Tainting