@@ -372,6 +372,19 @@ script_var_exists(char_u *name, size_t len, int vim9script, cctx_T *cctx)
372372 return FAIL ;
373373}
374374
375+ /*
376+ * Return TRUE if "name" is a local variable, argument, script variable or
377+ * imported.
378+ */
379+ static int
380+ variable_exists (char_u * name , size_t len , cctx_T * cctx )
381+ {
382+ return lookup_local (name , len , NULL , cctx ) == OK
383+ || arg_exists (name , len , NULL , NULL , NULL , cctx ) == OK
384+ || script_var_exists (name , len , FALSE, cctx ) == OK
385+ || find_imported (name , len , cctx ) != NULL ;
386+ }
387+
375388/*
376389 * Check if "p[len]" is already defined, either in script "import_sid" or in
377390 * compilation context "cctx". "cctx" is NULL at the script level.
@@ -6444,10 +6457,7 @@ may_compile_assignment(exarg_T *eap, char_u **line, cctx_T *cctx)
64446457 || * eap -> cmd == '$'
64456458 || * eap -> cmd == '@'
64466459 || ((len ) > 2 && eap -> cmd [1 ] == ':' )
6447- || lookup_local (eap -> cmd , len , NULL , cctx ) == OK
6448- || arg_exists (eap -> cmd , len , NULL , NULL , NULL , cctx ) == OK
6449- || script_var_exists (eap -> cmd , len , FALSE, cctx ) == OK
6450- || find_imported (eap -> cmd , len , cctx ) != NULL )
6460+ || variable_exists (eap -> cmd , len , cctx ))
64516461 {
64526462 * line = compile_assignment (eap -> cmd , eap , CMD_SIZE , cctx );
64536463 if (* line == NULL || * line == eap -> cmd )
@@ -8332,7 +8342,7 @@ compile_def_function(
83328342 }
83338343 }
83348344 p = find_ex_command (& ea , NULL , starts_with_colon ? NULL
8335- : (int (* )(char_u * , size_t , void * , cctx_T * ))lookup_local ,
8345+ : (int (* )(char_u * , size_t , cctx_T * ))variable_exists ,
83368346 & cctx );
83378347
83388348 if (p == NULL )
0 commit comments