Stop checking for matches once we reach a fun
Fix shadowing warning in case with function, closes #1524