Fix for issue where comments are lost in function definitions

Fixes #1710