Please add function name to the error message:
In case if user forget function ending end
keyword somewhere the whole code becomes one big function. Then any return call will throw mentioned error causing confusion and giving no further clues what's wrong.