Wow, so I guess I'm pretty much wrong about this... Sorry for the noise guys. I failed to consider different uses for functions, obviously, and it's not possible to automatically detect usages which could cause problems.
Perhaps this is more of a bug in the documentation than anything else. I couldn't find any documentation for the behavior for what will happen if a query is executed inside a function which is called from a check statement. I also couldn't find anything about calling function inside check statements in general, but perhaps that's not necessary. I do, however, think it should definitely be documented somewhere that functions cannot be used to get around the lack of check statement subqueries, because the ordering of operations is wrong.
Thanks!
Ari