fix error line number when a function is left open. fixes #4984

that'll teach me to use `set!`...