To: vim_dev@googlegroups.com Subject: Patch 8.2.1320 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1320 Problem: Vim9: cannot declare some single letter variables. Solution: Do not recognize a colon for a namespace for single letter variables. (closes #6547) Files: src/vim9compile.c, src/testdir/test_vim9_script.vim *** ../vim-8.2.1319/src/vim9compile.c 2020-07-28 20:06:46.115280293 +0200 --- src/vim9compile.c 2020-07-29 19:15:05.245224195 +0200 *************** *** 5237,5243 **** goto theend; } } ! else if (STRNCMP(var_start, "g:", 2) == 0) { dest = dest_global; if (is_decl) --- 5237,5243 ---- goto theend; } } ! else if (varlen > 1 && STRNCMP(var_start, "g:", 2) == 0) { dest = dest_global; if (is_decl) *************** *** 5246,5252 **** goto theend; } } ! else if (STRNCMP(var_start, "b:", 2) == 0) { dest = dest_buffer; if (is_decl) --- 5246,5252 ---- goto theend; } } ! else if (varlen > 1 && STRNCMP(var_start, "b:", 2) == 0) { dest = dest_buffer; if (is_decl) *************** *** 5255,5261 **** goto theend; } } ! else if (STRNCMP(var_start, "w:", 2) == 0) { dest = dest_window; if (is_decl) --- 5255,5261 ---- goto theend; } } ! else if (varlen > 1 && STRNCMP(var_start, "w:", 2) == 0) { dest = dest_window; if (is_decl) *************** *** 5264,5270 **** goto theend; } } ! else if (STRNCMP(var_start, "t:", 2) == 0) { dest = dest_tab; if (is_decl) --- 5264,5270 ---- goto theend; } } ! else if (varlen > 1 && STRNCMP(var_start, "t:", 2) == 0) { dest = dest_tab; if (is_decl) *************** *** 5273,5279 **** goto theend; } } ! else if (STRNCMP(var_start, "v:", 2) == 0) { typval_T *vtv; int di_flags; --- 5273,5279 ---- goto theend; } } ! else if (varlen > 1 && STRNCMP(var_start, "v:", 2) == 0) { typval_T *vtv; int di_flags; *************** *** 5337,5350 **** goto theend; } } ! else if (STRNCMP(var_start, "s:", 2) == 0 || lookup_script(var_start, varlen) == OK || find_imported(var_start, varlen, cctx) != NULL) { dest = dest_script; if (is_decl) { ! semsg(_("E1054: Variable already declared in the script: %s"), name); goto theend; } --- 5337,5354 ---- goto theend; } } ! else if ((varlen > 1 && STRNCMP(var_start, "s:", 2) == 0) || lookup_script(var_start, varlen) == OK || find_imported(var_start, varlen, cctx) != NULL) { dest = dest_script; if (is_decl) { ! if ((varlen > 1 && STRNCMP(var_start, "s:", 2) == 0)) ! semsg(_("E1101: Cannot declare a script variable in a function: %s"), ! name); ! else ! semsg(_("E1054: Variable already declared in the script: %s"), name); goto theend; } *** ../vim-8.2.1319/src/testdir/test_vim9_script.vim 2020-07-29 14:40:21.863245604 +0200 --- src/testdir/test_vim9_script.vim 2020-07-29 19:16:45.760739531 +0200 *************** *** 109,114 **** --- 109,117 ---- call CheckDefFailure(['&ts = 3', 'let asdf'], 'E1022:') &ts = 8 + call CheckDefFailure(['let s:var = 123'], 'E1101:') + call CheckDefFailure(['let s:var: number'], 'E1101:') + g:inc_counter += 1 assert_equal(2, g:inc_counter) *************** *** 136,141 **** --- 139,166 ---- assert_equal('noneagain', v:errmsg) call CheckDefFailure(['v:errmsg += "more"'], 'E1013:') call CheckDefFailure(['v:errmsg += 123'], 'E1013:') + + # single letter variables + a = 123 + assert_equal(123, a) + let b: number + b = 123 + assert_equal(123, b) + let g: number + g = 123 + assert_equal(123, g) + let s: number + s = 123 + assert_equal(123, s) + let t: number + t = 123 + assert_equal(123, t) + let v: number + v = 123 + assert_equal(123, v) + let w: number + w = 123 + assert_equal(123, w) enddef def Test_vim9_single_char_vars() *** ../vim-8.2.1319/src/version.c 2020-07-29 17:43:52.368173474 +0200 --- src/version.c 2020-07-29 19:17:06.508639521 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1320, /**/ -- From "know your smileys": @:-() Elvis Presley /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///