forked from aniani/vim
patch 8.2.2483: Vim9: type error for misformed expression
Problem: Vim9: type error for misformed expression. Solution: Check for end of command before checking type. (closes #7795)
This commit is contained in:
parent
a5a1ec1826
commit
6628b7ebff
@ -1743,6 +1743,21 @@ def Test_if_elseif_else_fails()
|
|||||||
CheckDefFailure(['endif'], 'E580:')
|
CheckDefFailure(['endif'], 'E580:')
|
||||||
CheckDefFailure(['if g:abool', 'elseif xxx'], 'E1001:')
|
CheckDefFailure(['if g:abool', 'elseif xxx'], 'E1001:')
|
||||||
CheckDefFailure(['if true', 'echo 1'], 'E171:')
|
CheckDefFailure(['if true', 'echo 1'], 'E171:')
|
||||||
|
|
||||||
|
var lines =<< trim END
|
||||||
|
var s = ''
|
||||||
|
if s = ''
|
||||||
|
endif
|
||||||
|
END
|
||||||
|
CheckDefFailure(lines, 'E488:')
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
var s = ''
|
||||||
|
if s == ''
|
||||||
|
elseif s = ''
|
||||||
|
endif
|
||||||
|
END
|
||||||
|
CheckDefFailure(lines, 'E488:')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
let g:bool_true = v:true
|
let g:bool_true = v:true
|
||||||
@ -2200,6 +2215,13 @@ def Test_while_loop_fails()
|
|||||||
CheckDefFailure(['break'], 'E587:')
|
CheckDefFailure(['break'], 'E587:')
|
||||||
CheckDefFailure(['if true', 'break'], 'E587:')
|
CheckDefFailure(['if true', 'break'], 'E587:')
|
||||||
CheckDefFailure(['while 1', 'echo 3'], 'E170:')
|
CheckDefFailure(['while 1', 'echo 3'], 'E170:')
|
||||||
|
|
||||||
|
var lines =<< trim END
|
||||||
|
var s = ''
|
||||||
|
while s = ''
|
||||||
|
endwhile
|
||||||
|
END
|
||||||
|
CheckDefFailure(lines, 'E488:')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_interrupt_loop()
|
def Test_interrupt_loop()
|
||||||
|
@ -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 */
|
||||||
|
/**/
|
||||||
|
2483,
|
||||||
/**/
|
/**/
|
||||||
2482,
|
2482,
|
||||||
/**/
|
/**/
|
||||||
|
@ -6701,6 +6701,11 @@ compile_if(char_u *arg, cctx_T *cctx)
|
|||||||
clear_ppconst(&ppconst);
|
clear_ppconst(&ppconst);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
if (!ends_excmd2(arg, skipwhite(p)))
|
||||||
|
{
|
||||||
|
semsg(_(e_trailing_arg), p);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
if (cctx->ctx_skip == SKIP_YES)
|
if (cctx->ctx_skip == SKIP_YES)
|
||||||
clear_ppconst(&ppconst);
|
clear_ppconst(&ppconst);
|
||||||
else if (instr->ga_len == instr_count && ppconst.pp_used == 1)
|
else if (instr->ga_len == instr_count && ppconst.pp_used == 1)
|
||||||
@ -6825,6 +6830,11 @@ compile_elseif(char_u *arg, cctx_T *cctx)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
cctx->ctx_skip = save_skip;
|
cctx->ctx_skip = save_skip;
|
||||||
|
if (!ends_excmd2(arg, skipwhite(p)))
|
||||||
|
{
|
||||||
|
semsg(_(e_trailing_arg), p);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
if (scope->se_skip_save == SKIP_YES)
|
if (scope->se_skip_save == SKIP_YES)
|
||||||
clear_ppconst(&ppconst);
|
clear_ppconst(&ppconst);
|
||||||
else if (instr->ga_len == instr_count && ppconst.pp_used == 1)
|
else if (instr->ga_len == instr_count && ppconst.pp_used == 1)
|
||||||
@ -7237,6 +7247,11 @@ compile_while(char_u *arg, cctx_T *cctx)
|
|||||||
// compile "expr"
|
// compile "expr"
|
||||||
if (compile_expr0(&p, cctx) == FAIL)
|
if (compile_expr0(&p, cctx) == FAIL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
if (!ends_excmd2(arg, skipwhite(p)))
|
||||||
|
{
|
||||||
|
semsg(_(e_trailing_arg), p);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (bool_on_stack(cctx) == FAIL)
|
if (bool_on_stack(cctx) == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user