diff src/eval.c @ 30217:e0cb5fb44859 v9.0.0444

patch 9.0.0444: trying to declare g:variable gives confusing error Commit: https://github.com/vim/vim/commit/9510d22463055f56548ff461ccbc54caa1ba1a2f Author: Bram Moolenaar <Bram@vim.org> Date: Sun Sep 11 15:14:05 2022 +0100 patch 9.0.0444: trying to declare g:variable gives confusing error Problem: Trying to declare g:variable gives confusing error. Solution: Give a better error message. (closes https://github.com/vim/vim/issues/11108)
author Bram Moolenaar <Bram@vim.org>
date Sun, 11 Sep 2022 16:15:04 +0200
parents a3016780f346
children c0f0118b6790
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -1031,12 +1031,16 @@ get_lval(
 	    {
 		char_u	    *tp = skipwhite(p + 1);
 
+		if (is_scoped_variable(name))
+		{
+		    semsg(_(e_cannot_use_type_with_this_variable_str), name);
+		    return NULL;
+		}
 		if (tp == p + 1 && !quiet)
 		{
 		    semsg(_(e_white_space_required_after_str_str), ":", p);
 		    return NULL;
 		}
-
 		if (!SCRIPT_ID_VALID(current_sctx.sc_sid))
 		{
 		    semsg(_(e_using_type_not_in_script_context_str), p);