Patch 8.2.2304
Problem: Vim9: no test for unletting an imported variable.
Solution: Add a test. Fix line number in error.
Files: src/vim9execute.c, src/testdir/test_vim9_assign.vim
*** ../vim-8.2.2303/src/vim9execute.c 2021-01-04 21:57:08.088222062 +0100
--- src/vim9execute.c 2021-01-05 20:57:10.719242090 +0100
***************
*** 1917,1922 ****
--- 1917,1923 ----
// unlet a dict item, index must be a string
if (tv_idx->v_type != VAR_STRING)
{
+ SOURCING_LNUM = iptr->isn_lnum;
semsg(_(e_expected_str_but_got_str),
vartype_name(VAR_STRING),
vartype_name(tv_idx->v_type));
***************
*** 1935,1940 ****
--- 1936,1942 ----
if (di == NULL)
{
// NULL dict is equivalent to empty dict
+ SOURCING_LNUM = iptr->isn_lnum;
semsg(_(e_dictkey), key);
status = FAIL;
}
***************
*** 1950,1955 ****
--- 1952,1958 ----
// unlet a List item, index must be a number
if (tv_idx->v_type != VAR_NUMBER)
{
+ SOURCING_LNUM = iptr->isn_lnum;
semsg(_(e_expected_str_but_got_str),
vartype_name(VAR_NUMBER),
vartype_name(tv_idx->v_type));
***************
*** 1964,1969 ****
--- 1967,1973 ----
li = list_find(l, n);
if (li == NULL)
{
+ SOURCING_LNUM = iptr->isn_lnum;
semsg(_(e_listidx), n);
status = FAIL;
}
***************
*** 3129,3134 ****
--- 3133,3139 ----
case ISN_2STRING:
case ISN_2STRING_ANY:
+ SOURCING_LNUM = iptr->isn_lnum;
if (do_2string(STACK_TV_BOT(iptr->isn_arg.number),
iptr->isn_type == ISN_2STRING_ANY) == FAIL)
goto on_error;
*** ../vim-8.2.2303/src/testdir/test_vim9_assign.vim 2021-01-04 21:57:08.088222062 +0100
--- src/testdir/test_vim9_assign.vim 2021-01-05 20:55:18.347567417 +0100
***************
*** 1349,1354 ****
--- 1349,1359 ----
assert_false(exists('s:somevar'))
unlet! s:somevar
+ CheckDefExecFailure([
+ 'var dd = 111',
+ 'unlet dd',
+ ], 'E1081:', 2)
+
# dict unlet
var dd = {a: 1, b: 2, c: 3}
unlet dd['a']
***************
*** 1367,1387 ****
assert_equal([{a: 1}, {c: 3}], dl)
CheckDefExecFailure([
! 'var ll = test_null_list()',
! 'unlet ll[0]',
! ], 'E684:')
! CheckDefExecFailure([
! 'var ll = [1]',
! 'unlet ll[2]',
! ], 'E684:')
! CheckDefExecFailure([
! 'var dd = test_null_dict()',
! 'unlet dd["a"]',
! ], 'E716:')
! CheckDefExecFailure([
! 'var dd = {a: 1}',
! 'unlet dd["b"]',
! ], 'E716:')
# can compile unlet before variable exists
g:someDict = {key: 'val'}
--- 1372,1400 ----
assert_equal([{a: 1}, {c: 3}], dl)
CheckDefExecFailure([
! 'var ll = test_null_list()',
! 'unlet ll[0]',
! ], 'E684:', 2)
! CheckDefExecFailure([
! 'var ll = [1]',
! 'unlet ll[2]',
! ], 'E684:', 2)
! CheckDefExecFailure([
! 'var ll = [1]',
! 'unlet ll[g:astring]',
! ], 'E39:', 2)
! CheckDefExecFailure([
! 'var dd = test_null_dict()',
! 'unlet dd["a"]',
! ], 'E716:', 2)
! CheckDefExecFailure([
! 'var dd = {a: 1}',
! 'unlet dd["b"]',
! ], 'E716:', 2)
! CheckDefExecFailure([
! 'var dd = {a: 1}',
! 'unlet dd[g:alist]',
! ], 'E1105:', 2)
# can compile unlet before variable exists
g:someDict = {key: 'val'}
***************
*** 1426,1431 ****
--- 1439,1456 ----
'defcompile',
], 'E1081:')
+ writefile(['vim9script', 'export var svar = 1234'], 'XunletExport.vim')
+ var lines =<< trim END
+ vim9script
+ import svar from './XunletExport.vim'
+ def UnletSvar()
+ unlet svar
+ enddef
+ defcompile
+ END
+ CheckScriptFailure(lines, 'E1081:', 1)
+ delete('XunletExport.vim')
+
$ENVVAR = 'foobar'
assert_equal('foobar', $ENVVAR)
unlet $ENVVAR
*** ../vim-8.2.2303/src/version.c 2021-01-05 19:23:25.088642148 +0100
--- src/version.c 2021-01-05 20:45:54.457132029 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2304,
/**/
--
From "know your smileys":
C=}>;*{)) Drunk, devilish chef with a toupee in an updraft,
a mustache, and a double chin
/// Bram Moolenaar -- Br...@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 ///