diff src/testdir/test_vim9_class.vim @ 32088:cdab211f342a v9.0.1375

patch 9.0.1375: crash when getting member of obj of unknown class Commit: https://github.com/vim/vim/commit/f77a7f704ffd0ca1050e82f609c8b8bd61863277 Author: Ernie Rael <errael@raelity.com> Date: Fri Mar 3 15:05:30 2023 +0000 patch 9.0.1375: crash when getting member of obj of unknown class Problem: Crash when getting member of obj of unknown class. Solution: Check for NULL class and give an error message. (Ernie Rael, closes #12096)
author Bram Moolenaar <Bram@vim.org>
date Fri, 03 Mar 2023 16:15:03 +0100
parents 615964c77be3
children 64e8cd965e79
line wrap: on
line diff
--- a/src/testdir/test_vim9_class.vim
+++ b/src/testdir/test_vim9_class.vim
@@ -272,6 +272,25 @@ def Test_object_not_set()
       echo Colorscheme.new(bg).GetBackground()
   END
   v9.CheckScriptFailure(lines, 'E1012: Type mismatch; expected object<Background> but got object<Unknown>')
+
+  # TODO: this should not give an error but be handled at runtime
+  lines =<< trim END
+      vim9script
+
+      class Class
+          this.id: string
+          def Method1()
+              echo 'Method1' .. this.id
+          enddef
+      endclass
+
+      var obj = null_object
+      def Func()
+          obj.Method1()
+      enddef
+      Func()
+  END
+  v9.CheckScriptFailure(lines, 'E1363:')
 enddef
 
 def Test_class_member_initializer()