Wrong error message in udefined variable error