In reply to MICRO_91:
User defined functions in constraints do not get in-lined. That is why all those rules about using function in constraints exist.
A function body that refers to variables outside the definition of the function body is a side-effect. The behavior is not defined.