forked from aniani/vim
patch 8.2.3239: Vim9: no error using heredoc for a number variable
Problem: Vim9: no error using heredoc for a number variable. Solution: Add a type check. (closes #8627)
This commit is contained in:
@@ -817,6 +817,7 @@ ex_let(exarg_T *eap)
|
|||||||
else if (expr[0] == '=' && expr[1] == '<' && expr[2] == '<')
|
else if (expr[0] == '=' && expr[1] == '<' && expr[2] == '<')
|
||||||
{
|
{
|
||||||
list_T *l;
|
list_T *l;
|
||||||
|
long cur_lnum = SOURCING_LNUM;
|
||||||
|
|
||||||
// HERE document
|
// HERE document
|
||||||
l = heredoc_get(eap, expr + 3, FALSE);
|
l = heredoc_get(eap, expr + 3, FALSE);
|
||||||
@@ -825,6 +826,8 @@ ex_let(exarg_T *eap)
|
|||||||
rettv_list_set(&rettv, l);
|
rettv_list_set(&rettv, l);
|
||||||
if (!eap->skip)
|
if (!eap->skip)
|
||||||
{
|
{
|
||||||
|
// errors are for the assignment, not the end marker
|
||||||
|
SOURCING_LNUM = cur_lnum;
|
||||||
op[0] = '=';
|
op[0] = '=';
|
||||||
op[1] = NUL;
|
op[1] = NUL;
|
||||||
(void)ex_let_vars(eap->arg, &rettv, FALSE, semicolon, var_count,
|
(void)ex_let_vars(eap->arg, &rettv, FALSE, semicolon, var_count,
|
||||||
|
@@ -1392,6 +1392,14 @@ def Test_heredoc()
|
|||||||
[END]
|
[END]
|
||||||
CheckScriptFailure(lines, 'E1145: Missing heredoc end marker: END')
|
CheckScriptFailure(lines, 'E1145: Missing heredoc end marker: END')
|
||||||
delfunc! g:Func
|
delfunc! g:Func
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
var lines: number =<< trim STOP
|
||||||
|
aaa
|
||||||
|
bbb
|
||||||
|
STOP
|
||||||
|
END
|
||||||
|
CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected number but got list<string>', 1)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_var_func_call()
|
def Test_var_func_call()
|
||||||
|
@@ -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 */
|
||||||
|
/**/
|
||||||
|
3239,
|
||||||
/**/
|
/**/
|
||||||
3238,
|
3238,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -6875,7 +6875,15 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
|
|||||||
if (compile_assign_lhs(var_start, &lhs, cmdidx,
|
if (compile_assign_lhs(var_start, &lhs, cmdidx,
|
||||||
is_decl, heredoc, oplen, cctx) == FAIL)
|
is_decl, heredoc, oplen, cctx) == FAIL)
|
||||||
goto theend;
|
goto theend;
|
||||||
if (!heredoc)
|
if (heredoc)
|
||||||
|
{
|
||||||
|
SOURCING_LNUM = start_lnum;
|
||||||
|
if (lhs.lhs_has_type
|
||||||
|
&& need_type(&t_list_string, lhs.lhs_type,
|
||||||
|
-1, 0, cctx, FALSE, FALSE) == FAIL)
|
||||||
|
goto theend;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (cctx->ctx_skip == SKIP_YES)
|
if (cctx->ctx_skip == SKIP_YES)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user