mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.2.2304: Vim9: no test for unletting an imported variable
Problem: Vim9: no test for unletting an imported variable. Solution: Add a test. Fix line number in error.
This commit is contained in:
@@ -1349,6 +1349,11 @@ def Test_unlet()
|
|||||||
assert_false(exists('s:somevar'))
|
assert_false(exists('s:somevar'))
|
||||||
unlet! s:somevar
|
unlet! s:somevar
|
||||||
|
|
||||||
|
CheckDefExecFailure([
|
||||||
|
'var dd = 111',
|
||||||
|
'unlet dd',
|
||||||
|
], 'E1081:', 2)
|
||||||
|
|
||||||
# dict unlet
|
# dict unlet
|
||||||
var dd = {a: 1, b: 2, c: 3}
|
var dd = {a: 1, b: 2, c: 3}
|
||||||
unlet dd['a']
|
unlet dd['a']
|
||||||
@@ -1367,21 +1372,29 @@ def Test_unlet()
|
|||||||
assert_equal([{a: 1}, {c: 3}], dl)
|
assert_equal([{a: 1}, {c: 3}], dl)
|
||||||
|
|
||||||
CheckDefExecFailure([
|
CheckDefExecFailure([
|
||||||
'var ll = test_null_list()',
|
'var ll = test_null_list()',
|
||||||
'unlet ll[0]',
|
'unlet ll[0]',
|
||||||
], 'E684:')
|
], 'E684:', 2)
|
||||||
CheckDefExecFailure([
|
CheckDefExecFailure([
|
||||||
'var ll = [1]',
|
'var ll = [1]',
|
||||||
'unlet ll[2]',
|
'unlet ll[2]',
|
||||||
], 'E684:')
|
], 'E684:', 2)
|
||||||
CheckDefExecFailure([
|
CheckDefExecFailure([
|
||||||
'var dd = test_null_dict()',
|
'var ll = [1]',
|
||||||
'unlet dd["a"]',
|
'unlet ll[g:astring]',
|
||||||
], 'E716:')
|
], 'E39:', 2)
|
||||||
CheckDefExecFailure([
|
CheckDefExecFailure([
|
||||||
'var dd = {a: 1}',
|
'var dd = test_null_dict()',
|
||||||
'unlet dd["b"]',
|
'unlet dd["a"]',
|
||||||
], 'E716:')
|
], '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
|
# can compile unlet before variable exists
|
||||||
g:someDict = {key: 'val'}
|
g:someDict = {key: 'val'}
|
||||||
@@ -1426,6 +1439,18 @@ def Test_unlet()
|
|||||||
'defcompile',
|
'defcompile',
|
||||||
], 'E1081:')
|
], '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'
|
$ENVVAR = 'foobar'
|
||||||
assert_equal('foobar', $ENVVAR)
|
assert_equal('foobar', $ENVVAR)
|
||||||
unlet $ENVVAR
|
unlet $ENVVAR
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2304,
|
||||||
/**/
|
/**/
|
||||||
2303,
|
2303,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -1917,6 +1917,7 @@ call_def_function(
|
|||||||
// unlet a dict item, index must be a string
|
// unlet a dict item, index must be a string
|
||||||
if (tv_idx->v_type != VAR_STRING)
|
if (tv_idx->v_type != VAR_STRING)
|
||||||
{
|
{
|
||||||
|
SOURCING_LNUM = iptr->isn_lnum;
|
||||||
semsg(_(e_expected_str_but_got_str),
|
semsg(_(e_expected_str_but_got_str),
|
||||||
vartype_name(VAR_STRING),
|
vartype_name(VAR_STRING),
|
||||||
vartype_name(tv_idx->v_type));
|
vartype_name(tv_idx->v_type));
|
||||||
@@ -1935,6 +1936,7 @@ call_def_function(
|
|||||||
if (di == NULL)
|
if (di == NULL)
|
||||||
{
|
{
|
||||||
// NULL dict is equivalent to empty dict
|
// NULL dict is equivalent to empty dict
|
||||||
|
SOURCING_LNUM = iptr->isn_lnum;
|
||||||
semsg(_(e_dictkey), key);
|
semsg(_(e_dictkey), key);
|
||||||
status = FAIL;
|
status = FAIL;
|
||||||
}
|
}
|
||||||
@@ -1950,6 +1952,7 @@ call_def_function(
|
|||||||
// unlet a List item, index must be a number
|
// unlet a List item, index must be a number
|
||||||
if (tv_idx->v_type != VAR_NUMBER)
|
if (tv_idx->v_type != VAR_NUMBER)
|
||||||
{
|
{
|
||||||
|
SOURCING_LNUM = iptr->isn_lnum;
|
||||||
semsg(_(e_expected_str_but_got_str),
|
semsg(_(e_expected_str_but_got_str),
|
||||||
vartype_name(VAR_NUMBER),
|
vartype_name(VAR_NUMBER),
|
||||||
vartype_name(tv_idx->v_type));
|
vartype_name(tv_idx->v_type));
|
||||||
@@ -1964,6 +1967,7 @@ call_def_function(
|
|||||||
li = list_find(l, n);
|
li = list_find(l, n);
|
||||||
if (li == NULL)
|
if (li == NULL)
|
||||||
{
|
{
|
||||||
|
SOURCING_LNUM = iptr->isn_lnum;
|
||||||
semsg(_(e_listidx), n);
|
semsg(_(e_listidx), n);
|
||||||
status = FAIL;
|
status = FAIL;
|
||||||
}
|
}
|
||||||
@@ -3129,6 +3133,7 @@ call_def_function(
|
|||||||
|
|
||||||
case ISN_2STRING:
|
case ISN_2STRING:
|
||||||
case ISN_2STRING_ANY:
|
case ISN_2STRING_ANY:
|
||||||
|
SOURCING_LNUM = iptr->isn_lnum;
|
||||||
if (do_2string(STACK_TV_BOT(iptr->isn_arg.number),
|
if (do_2string(STACK_TV_BOT(iptr->isn_arg.number),
|
||||||
iptr->isn_type == ISN_2STRING_ANY) == FAIL)
|
iptr->isn_type == ISN_2STRING_ANY) == FAIL)
|
||||||
goto on_error;
|
goto on_error;
|
||||||
|
Reference in New Issue
Block a user