Improve syntax error on invalid calls

Closes #1847