0
0
mirror of https://github.com/vim/vim.git synced 2025-09-30 04:44:14 -04:00

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.
This commit is contained in:
Bram Moolenaar
2020-05-15 18:17:28 +02:00
parent a5d0077efb
commit 227a69de1e
4 changed files with 47 additions and 11 deletions

View File

@@ -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:')
delete('Xfinished')
lines =<< trim END
vim9script
let var = g:unkown
END
CheckScriptFailure(lines, 'E1091:')
" 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()