I hypothesize that it uses assignin(), or that you are doing a load() that is "poofing" variables into existence. These days inside a function the Just In Time Compiler prefers to use syntactic scope instead of dynamic scope. For example,
then JIT will assume that the load is not creating sin and that myscript is not creating sin.
If you have functions that are using assignin() to assign to a variable that might not exist, or if you are using a script to assign to a variable that might not exist, or you are using load() to "poof" a function into existence, or you are using load() to "poof" a variable into existence which has the same name as any function on your MATLAB path -- then assign something (anything) to the variable before calling the magic code, so that JIT knows that the name is going to refer to a variable later.