mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.2.1512: failure after trinary expression fails
Problem: Failure after trinary expression fails. Solution: Restore eval_flags. (Yasuhiro Matsumoto, closes #6776)
This commit is contained in:
@@ -2167,7 +2167,10 @@ eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
|||||||
evalarg_used->eval_flags = result ? orig_flags
|
evalarg_used->eval_flags = result ? orig_flags
|
||||||
: orig_flags & ~EVAL_EVALUATE;
|
: orig_flags & ~EVAL_EVALUATE;
|
||||||
if (eval1(arg, rettv, evalarg_used) == FAIL)
|
if (eval1(arg, rettv, evalarg_used) == FAIL)
|
||||||
|
{
|
||||||
|
evalarg_used->eval_flags = orig_flags;
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for the ":".
|
* Check for the ":".
|
||||||
@@ -2178,6 +2181,7 @@ eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
|||||||
emsg(_(e_missing_colon));
|
emsg(_(e_missing_colon));
|
||||||
if (evaluate && result)
|
if (evaluate && result)
|
||||||
clear_tv(rettv);
|
clear_tv(rettv);
|
||||||
|
evalarg_used->eval_flags = orig_flags;
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
if (getnext)
|
if (getnext)
|
||||||
@@ -2188,6 +2192,7 @@ eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
|||||||
{
|
{
|
||||||
error_white_both(p, 1);
|
error_white_both(p, 1);
|
||||||
clear_tv(rettv);
|
clear_tv(rettv);
|
||||||
|
evalarg_used->eval_flags = orig_flags;
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
*arg = p;
|
*arg = p;
|
||||||
@@ -2200,6 +2205,7 @@ eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
|||||||
{
|
{
|
||||||
error_white_both(p, 1);
|
error_white_both(p, 1);
|
||||||
clear_tv(rettv);
|
clear_tv(rettv);
|
||||||
|
evalarg_used->eval_flags = orig_flags;
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
*arg = skipwhite_and_linebreak(*arg + 1, evalarg_used);
|
*arg = skipwhite_and_linebreak(*arg + 1, evalarg_used);
|
||||||
@@ -2209,6 +2215,7 @@ eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
|||||||
{
|
{
|
||||||
if (evaluate && result)
|
if (evaluate && result)
|
||||||
clear_tv(rettv);
|
clear_tv(rettv);
|
||||||
|
evalarg_used->eval_flags = orig_flags;
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
if (evaluate && !result)
|
if (evaluate && !result)
|
||||||
|
@@ -114,6 +114,27 @@ def Test_expr1_vimscript()
|
|||||||
let var = v:true ? 1 :2
|
let var = v:true ? 1 :2
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1004:', 2)
|
CheckScriptFailure(lines, 'E1004:', 2)
|
||||||
|
|
||||||
|
# check after failure eval_flags is reset
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
try
|
||||||
|
call eval('0 ? 1: 2')
|
||||||
|
catch
|
||||||
|
endtry
|
||||||
|
assert_equal(v:true, eval(string(v:true)))
|
||||||
|
END
|
||||||
|
CheckScriptSuccess(lines)
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
try
|
||||||
|
call eval('0 ? 1 :2')
|
||||||
|
catch
|
||||||
|
endtry
|
||||||
|
assert_equal(v:true, eval(string(v:true)))
|
||||||
|
END
|
||||||
|
CheckScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
func Test_expr1_fails()
|
func Test_expr1_fails()
|
||||||
|
@@ -7445,6 +7445,30 @@ func Test_typed_script_var()
|
|||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for issue6776 {{{1
|
||||||
|
func Test_trinary_expression()
|
||||||
|
try
|
||||||
|
call eval('0 ? 0')
|
||||||
|
catch
|
||||||
|
endtry
|
||||||
|
" previous failure should not cause next expression to fail
|
||||||
|
call assert_equal(v:false, eval(string(v:false)))
|
||||||
|
|
||||||
|
try
|
||||||
|
call eval('0 ? "burp')
|
||||||
|
catch
|
||||||
|
endtry
|
||||||
|
" previous failure should not cause next expression to fail
|
||||||
|
call assert_equal(v:false, eval(string(v:false)))
|
||||||
|
|
||||||
|
try
|
||||||
|
call eval('1 ? 0 : "burp')
|
||||||
|
catch
|
||||||
|
endtry
|
||||||
|
" previous failure should not cause next expression to fail
|
||||||
|
call assert_equal(v:false, eval(string(v:false)))
|
||||||
|
endfunction
|
||||||
|
|
||||||
"-------------------------------------------------------------------------------
|
"-------------------------------------------------------------------------------
|
||||||
" Modelines {{{1
|
" Modelines {{{1
|
||||||
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
|
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
|
||||||
|
@@ -754,6 +754,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 */
|
||||||
|
/**/
|
||||||
|
1512,
|
||||||
/**/
|
/**/
|
||||||
1511,
|
1511,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user