diff src/testdir/test_vim9_class.vim @ 35274:f9b2a9511769 v9.1.0445

patch 9.1.0445: Coverity warning after 9.1.0440 Commit: https://github.com/vim/vim/commit/dbac0da631c66869f41c3c573ad7a8cfef95964d Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Sat May 25 20:23:54 2024 +0200 patch 9.1.0445: Coverity warning after 9.1.0440 Problem: Coverity warning after 9.1.0440 Solution: Fix Coverity warning, add a test and reduce the calls to clear_tv() (Yegappan Lakshmanan). closes: #14845 Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sat, 25 May 2024 20:30:03 +0200
parents 12afa965d56e
children 047733a6b42b
line wrap: on
line diff
--- a/src/testdir/test_vim9_class.vim
+++ b/src/testdir/test_vim9_class.vim
@@ -10724,4 +10724,24 @@ def Test_class_definition_in_a_function(
   v9.CheckScriptFailure(lines, 'E1429: Class can only be used in a script', 1)
 enddef
 
+" Test for using [] with a class and an object
+def Test_class_object_index()
+  var lines =<< trim END
+    vim9script
+    class A
+    endclass
+    A[10] = 1
+  END
+  v9.CheckScriptFailure(lines, 'E689: Index not allowed after a class: A[10] = 1', 4)
+
+  lines =<< trim END
+    vim9script
+    class A
+    endclass
+    var a = A.new()
+    a[10] = 1
+  END
+  v9.CheckScriptFailure(lines, 'E689: Index not allowed after a object: a[10] = 1', 5)
+enddef
+
 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker