vim-patch:8.2.1756: Vim9: :let will soon be disallowed (#37063)

Problem:    Vim9: :let will soon be disallowed.
Solution:   Add v:disallow_let temporarily.  Fix tests.

cfcd011fcd

The change to use checkforcmd() is already included in the port of patch
9.0.1505. This commit adds the missing :const check.

N/A patches:
vim-patch:8.2.1397: Vim9: return type of maparg() not adjusted for fourth arg
vim-patch:8.2.1623: Vim9: using :call where it is not needed
vim-patch:8.2.1766: Vim9: Some tests are still using :let
vim-patch:8.2.1788: Vim9: still allows :let for declarations
vim-patch:8.2.1882: Vim9: v:disallow_let is no longer needed

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq
2025-12-22 12:31:44 +08:00
committed by GitHub
parent 6c7a5eff1d
commit b95848a8f1
2 changed files with 17 additions and 3 deletions

View File

@@ -2552,10 +2552,11 @@ static int get_function_body(exarg_T *eap, garray_T *newlines, char *line_arg_in
}
if (!is_heredoc) {
// Check for ":let v =<< [trim] EOF"
// and ":let [a, b] =<< [trim] EOF"
// Check for ":cmd v =<< [trim] EOF"
// and ":cmd [a, b] =<< [trim] EOF"
// Where "cmd" can be "let" or "const".
arg = p;
if (checkforcmd(&arg, "let", 2)) {
if (checkforcmd(&arg, "let", 2) || checkforcmd(&p, "const", 5)) {
int var_count = 0;
int semicolon = 0;
arg = (char *)skip_var_list(arg, &var_count, &semicolon, true);

View File

@@ -116,6 +116,19 @@ func Test_maparg()
unlet d
endfunc
" def Test_vim9_maparg()
" nmap { w
" var one: string = maparg('{')
" assert_equal('w', one)
" var two: string = maparg('{', 'n')
" assert_equal('w', two)
" var three: string = maparg('{', 'n', 0)
" assert_equal('w', three)
" var four: dict<any> = maparg('{', 'n', 0, 1)
" assert_equal(['{', 'w', 'n'], [four.lhs, four.rhs, four.mode])
" nunmap {
" enddef
func Test_mapcheck()
call assert_equal('', mapcheck('a'))
call assert_equal('', mapcheck('abc'))