diff src/testdir/test_vim9_script.vim @ 20401:918b9a05cf35 v8.2.0755

patch 8.2.0755: Vim9: No error when variable initializer is not a constant Commit: https://github.com/vim/vim/commit/227a69de1e0f9457a9fc9e098d999304faff55f8 Author: Bram Moolenaar <Bram@vim.org> Date: Fri May 15 18:17:28 2020 +0200 patch 8.2.0755: Vim9: No error when variable initializer is not a constant Problem: Vim9: No error when variable initializer is not a constant. Solution: Return FAIL when trying to get a variable value. Do not execute a script when an error is deteted in the first or second phase.
author Bram Moolenaar <Bram@vim.org>
date Fri, 15 May 2020 18:30:04 +0200
parents d1a54d2bd145
children d54dfb5f12db
line wrap: on
line diff
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -494,8 +494,8 @@ let s:export_script_lines =<< trim END
   def Concat(arg: string): string
     return name .. arg
   enddef
-  let g:result: string = Concat('bie')
-  let g:localname = name
+  g:result = Concat('bie')
+  g:localname = name
 
   export const CONST = 1234
   export let exported = 9876
@@ -1747,10 +1747,34 @@ def Test_let_missing_type()
     endfunc
     let val = GetValue() 
   END
-  writefile(lines, 'Xfinished')
-  assert_fails('source Xfinished', 'E1091:')
+  CheckScriptFailure(lines, 'E1091:')
+
+  lines =<< trim END
+    vim9script
+    let var = g:unkown
+  END
+  CheckScriptFailure(lines, 'E1091:')
 
-  delete('Xfinished')
+  " TODO: eventually this would work
+  lines =<< trim END
+    vim9script
+    let var = has('eval')
+  END
+  CheckScriptFailure(lines, 'E1091:')
+
+  " TODO: eventually this would work
+  lines =<< trim END
+    vim9script
+    let var = len('string')
+  END
+  CheckScriptFailure(lines, 'E1091:')
+
+  lines =<< trim END
+    vim9script
+    let nr: number = 123
+    let var = nr
+  END
+  CheckScriptFailure(lines, 'E1091:')
 enddef
 
 def Test_forward_declaration()