patch 9.0.2181: Vim9: missing error messages

Commit: 
https://github.com/vim/vim/commit/5e133157785dd2fdcfaaecd4822f2793e28b466d
Author: Ernie Rael <err...@raelity.com>
Date:   Tue Dec 19 22:15:27 2023 +0100

    patch 9.0.2181: Vim9: missing error messages
    
    Problem:  Vim9: missing error messages
    Solution: Add one more error message
    
    closes: #13729
    
    Signed-off-by: Ernie Rael <err...@raelity.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/errors.h b/src/errors.h
index 5eac96123..828e8de24 100644
--- a/src/errors.h
+++ b/src/errors.h
@@ -3574,8 +3574,10 @@ EXTERN char 
e_cannot_change_readonly_variable_str_in_class_str[]
        INIT(= N_("E1409: Cannot change read-only variable \"%s\" in class 
\"%s\""));
 EXTERN char e_const_variable_not_supported_in_interface[]
        INIT(= N_("E1410: Const variable not supported in an interface"));
+EXTERN char e_missing_dot_after_object_str[]
+       INIT(= N_("E1411: Missing dot after object \"%s\""));
 #endif
-// E1411 - E1499 unused (reserved for Vim9 class support)
+// E1412 - E1499 unused (reserved for Vim9 class support)
 EXTERN char e_cannot_mix_positional_and_non_positional_str[]
        INIT(= N_("E1500: Cannot mix positional and non-positional arguments: 
%s"));
 EXTERN char e_fmt_arg_nr_unused_str[]
diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim
index c6828e32d..f90469611 100644
--- a/src/testdir/test_vim9_assign.vim
+++ b/src/testdir/test_vim9_assign.vim
@@ -3174,6 +3174,31 @@ def Test_type_check()
     END
     v9.CheckSourceSuccess(lines)
   endif
+
+  lines =<< trim END
+    vim9script
+    class A
+    endclass
+
+    def F()
+      A += 3
+    enddef
+    F()
+  END
+  v9.CheckScriptFailure(lines, 'E1405: Class "A" cannot be used as a value')
+
+  lines =<< trim END
+    vim9script
+    class A
+    endclass
+
+    var o = A.new()
+    def F()
+      o += 4
+    enddef
+    F()
+  END
+  v9.CheckScriptFailure(lines, 'E1411: Missing dot after object "o"')
 enddef
 
 " Test for checking the argument type of a def function
diff --git a/src/version.c b/src/version.c
index 3f636c7a3..316e63892 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2181,
 /**/
     2180,
 /**/
diff --git a/src/vim9compile.c b/src/vim9compile.c
index b896f43d3..17a3b6a5c 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -2265,7 +2265,10 @@ compile_load_lhs_with_index(lhs_T *lhs, char_u 
*var_start, cctx_T *cctx)
        // Also for "obj.value".
        char_u *dot = vim_strchr(var_start, '.');
        if (dot == NULL)
+       {
+          semsg(_(e_missing_dot_after_object_str), lhs->lhs_name);
           return FAIL;
+       }
 
        class_T *cl = lhs->lhs_type->tt_class;
        type_T  *type = oc_member_type(cl, TRUE, dot + 1,
@@ -2294,7 +2297,10 @@ compile_load_lhs_with_index(lhs_T *lhs, char_u 
*var_start, cctx_T *cctx)
        // "<classname>.value": load class variable "classname.value"
        char_u *dot = vim_strchr(var_start, '.');
        if (dot == NULL)
+       {
+          check_type_is_value(lhs->lhs_type);
           return FAIL;
+       }
 
        class_T *cl = lhs->lhs_type->tt_class;
        ocmember_T *m = class_member_lookup(cl, dot + 1,

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/E1rFhf9-003jD5-2j%40256bit.org.

Raspunde prin e-mail lui