How to save a user-defined function

This problem should be fixed by this PR

Thank you for reporting the issue. It was broken since 6.04