mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.3144: Vim9: no error when using an invalid value for a line number
Problem: Vim9: no error when using an invalid value for a line number. Solution: Give an error if the string value is not recognized. (closes #8536)
This commit is contained in:
@@ -498,3 +498,5 @@ EXTERN char e_expression_without_effect_str[]
|
|||||||
INIT(= N_("E1207: Expression without an effect: %s"));
|
INIT(= N_("E1207: Expression without an effect: %s"));
|
||||||
EXTERN char e_complete_used_without_nargs[]
|
EXTERN char e_complete_used_without_nargs[]
|
||||||
INIT(= N_("E1208: -complete used without -nargs"));
|
INIT(= N_("E1208: -complete used without -nargs"));
|
||||||
|
EXTERN char e_invalid_value_for_line_number_str[]
|
||||||
|
INIT(= N_("E1209: Invalid value for a line number: \"%s\""));
|
||||||
|
@@ -5376,6 +5376,8 @@ var2fpos(
|
|||||||
}
|
}
|
||||||
return &pos;
|
return &pos;
|
||||||
}
|
}
|
||||||
|
if (in_vim9script())
|
||||||
|
semsg(_(e_invalid_value_for_line_number_str), name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -474,7 +474,7 @@ def Test_cursor()
|
|||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
cursor('2', 1)
|
cursor('2', 1)
|
||||||
END
|
END
|
||||||
CheckDefExecAndScriptFailure(lines, 'E475:')
|
CheckDefExecAndScriptFailure(lines, 'E1209:')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_debugbreak()
|
def Test_debugbreak()
|
||||||
@@ -1036,6 +1036,25 @@ def Test_getjumplist()
|
|||||||
CheckDefFailure(['getjumplist(1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string')
|
CheckDefFailure(['getjumplist(1, "x")'], 'E1013: Argument 2: type mismatch, expected number but got string')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_getline()
|
||||||
|
var lines =<< trim END
|
||||||
|
new
|
||||||
|
setline(1, ['hello', 'there', 'again'])
|
||||||
|
assert_equal('hello', getline(1))
|
||||||
|
assert_equal('hello', getline('.'))
|
||||||
|
|
||||||
|
normal 2Gvjv
|
||||||
|
assert_equal('there', getline("'<"))
|
||||||
|
assert_equal('again', getline("'>"))
|
||||||
|
END
|
||||||
|
CheckDefAndScriptSuccess(lines)
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
echo getline('1')
|
||||||
|
END
|
||||||
|
CheckDefExecAndScriptFailure(lines, 'E1209:')
|
||||||
|
enddef
|
||||||
|
|
||||||
def Test_getmarklist()
|
def Test_getmarklist()
|
||||||
CheckDefFailure(['getmarklist([])'], 'E1013: Argument 1: type mismatch, expected string but got list<unknown>')
|
CheckDefFailure(['getmarklist([])'], 'E1013: Argument 1: type mismatch, expected string but got list<unknown>')
|
||||||
assert_equal([], getmarklist(10000))
|
assert_equal([], getmarklist(10000))
|
||||||
@@ -1049,7 +1068,7 @@ enddef
|
|||||||
def Test_getpos()
|
def Test_getpos()
|
||||||
CheckDefFailure(['getpos(10)'], 'E1013: Argument 1: type mismatch, expected string but got number')
|
CheckDefFailure(['getpos(10)'], 'E1013: Argument 1: type mismatch, expected string but got number')
|
||||||
assert_equal([0, 1, 1, 0], getpos('.'))
|
assert_equal([0, 1, 1, 0], getpos('.'))
|
||||||
assert_equal([0, 0, 0, 0], getpos('a'))
|
CheckDefExecFailure(['getpos("a")'], 'E1209:')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_getqflist()
|
def Test_getqflist()
|
||||||
|
@@ -755,6 +755,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 */
|
||||||
|
/**/
|
||||||
|
3144,
|
||||||
/**/
|
/**/
|
||||||
3143,
|
3143,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user