Mercurial > vim
diff src/userfunc.c @ 23808:baf9069f64ca v8.2.2445
patch 8.2.2445: Vim9: no proper error for lambda missing return type
Commit: https://github.com/vim/vim/commit/0346b799fc228a3b48967ca0747e6b23586dbaa6
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 31 22:18:29 2021 +0100
patch 8.2.2445: Vim9: no proper error for lambda missing return type
Problem: Vim9: no proper error for lambda missing return type.
Solution: Check for this error. (closes https://github.com/vim/vim/issues/7758)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 31 Jan 2021 22:30:03 +0100 |
parents | 7d0959080545 |
children | 950875545045 |
line wrap: on
line diff
--- a/src/userfunc.c +++ b/src/userfunc.c @@ -491,6 +491,11 @@ skip_arrow( s = skipwhite(s + 1); *ret_type = s; s = skip_type(s, TRUE); + if (s == *ret_type) + { + emsg(_(e_missing_return_type)); + return NULL; + } } bef = s; s = skipwhite(s); @@ -543,6 +548,7 @@ get_lambda_tv( char_u *tofree2 = NULL; int equal_arrow = **arg == '('; int white_error = FALSE; + int called_emsg_start = called_emsg; if (equal_arrow && !in_vim9script()) return NOTDONE; @@ -560,7 +566,7 @@ get_lambda_tv( { if (types_optional) ga_clear_strings(&argtypes); - return NOTDONE; + return called_emsg == called_emsg_start ? NOTDONE : FAIL; } // Parse the arguments for real.