Exit gracefully if an external function name is used as a model local variable.

Closes #599
(cherry picked from commit 535af2d536bda159d3b3820b77e94c9f07ceaf88)