Fix Defining function after return causes error (fix #326)