From 52c124d3303d3cc3e4504708881906d17d6d6c55 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 20 Dec 2020 21:43:35 +0100 Subject: [PATCH] patch 8.2.2173: Vim9: get internal error when assigning to undefined variable Problem: Vim9: get internal error when assigning to undefined variable. Solution: Add error message. (closes #7475) --- src/errors.h | 2 ++ src/testdir/test_vim9_cmd.vim | 11 +++++++++++ src/version.c | 2 ++ src/vim9compile.c | 5 +++-- src/vim9execute.c | 3 +-- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/errors.h b/src/errors.h index e761a4ea4..023c1d1c6 100644 --- a/src/errors.h +++ b/src/errors.h @@ -321,3 +321,5 @@ EXTERN char e_command_not_followed_by_white_space_str[] INIT(= N_("E1144: Command is not followed by white space: %s")); EXTERN char e_missing_heredoc_end_marker_str[] INIT(= N_("E1145: Missing heredoc end marker: %s")); +EXTERN char e_command_not_recognized_str[] + INIT(= N_("E1146: Command not recognized: %s")); diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim index bdc9ad06d..d297931bc 100644 --- a/src/testdir/test_vim9_cmd.vim +++ b/src/testdir/test_vim9_cmd.vim @@ -710,5 +710,16 @@ def Test_ambiguous_user_cmd() CheckScriptFailure(lines, 'E464:') enddef +def Test_command_not_recognized() + var lines =<< trim END + d.key = 'asdf' + END + CheckDefFailure(lines, 'E1146:', 1) + + lines =<< trim END + d['key'] = 'asdf' + END + CheckDefFailure(lines, 'E1146:', 1) +enddef " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker diff --git a/src/version.c b/src/version.c index f374d43e6..1a45c95ca 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2173, /**/ 2172, /**/ diff --git a/src/vim9compile.c b/src/vim9compile.c index 9bd36981a..133a09cc9 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -7681,8 +7681,9 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx) // Expression or function call. if (ea.cmdidx != CMD_eval) { - // CMD_var cannot happen, compile_assignment() above is used - iemsg("Command from find_ex_command() not handled"); + // CMD_var cannot happen, compile_assignment() above would be + // used. Most likely an assignment to a non-existing variable. + semsg(_(e_command_not_recognized_str), ea.cmd); goto erret; } } diff --git a/src/vim9execute.c b/src/vim9execute.c index 606ce0cd3..db15cea4c 100644 --- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -606,8 +606,7 @@ call_ufunc(ufunc_T *ufunc, int argcount, ectx_T *ectx, isn_T *iptr) return FAIL; if (ufunc->uf_def_status == UF_COMPILED) { - int error = check_user_func_argcount(ufunc, argcount); - + error = check_user_func_argcount(ufunc, argcount); if (error != FCERR_UNKNOWN) { if (error == FCERR_TOOMANY) -- 2.40.0