comparison src/testdir/test_vim9_class.vim @ 31970:fe66019e7a23 v9.0.1317

patch 9.0.1317: crash when using an unset object variable Commit: https://github.com/vim/vim/commit/552bdca781bd202012224316ffae3439aac83b7b Author: Bram Moolenaar <Bram@vim.org> Date: Fri Feb 17 21:08:50 2023 +0000 patch 9.0.1317: crash when using an unset object variable Problem: Crash when using an unset object variable. Solution: Give an error instead. (closes https://github.com/vim/vim/issues/12005)
author Bram Moolenaar <Bram@vim.org>
date Fri, 17 Feb 2023 22:15:05 +0100
parents 7b1cbb43506c
children 4e59c4260d84
comparison
equal deleted inserted replaced
31969:39d6012603df 31970:fe66019e7a23
178 export interface AnotherName 178 export interface AnotherName
179 this.member: string 179 this.member: string
180 endclass 180 endclass
181 END 181 END
182 v9.CheckScriptFailure(lines, 'E476: Invalid command: endclass, expected endinterface') 182 v9.CheckScriptFailure(lines, 'E476: Invalid command: endclass, expected endinterface')
183 enddef
184
185 def Test_object_not_set()
186 var lines =<< trim END
187 vim9script
188
189 class State
190 this.value = 'xyz'
191 endclass
192
193 var state: State
194 var db = {'xyz': 789}
195 echo db[state.value]
196 END
197 v9.CheckScriptFailure(lines, 'E1360:')
183 enddef 198 enddef
184 199
185 def Test_class_member_initializer() 200 def Test_class_member_initializer()
186 var lines =<< trim END 201 var lines =<< trim END
187 vim9script 202 vim9script