Patch 8.2.1512
Problem: Failure after trinary expression fails.
Solution: Restore eval_flags. (Yasuhiro Matsumoto, closes #6776)
Files: src/eval.c, src/testdir/test_vimscript.vim,
src/testdir/test_vim9_expr.vim
*** ../vim-8.2.1511/src/eval.c 2020-08-22 15:19:13.928593727 +0200
--- src/eval.c 2020-08-22 22:36:18.081303245 +0200
***************
*** 2167,2173 ****
--- 2167,2176 ----
evalarg_used->eval_flags = result ? orig_flags
: orig_flags & ~EVAL_EVALUATE;
if (eval1(arg, rettv, evalarg_used) == FAIL)
+ {
+ evalarg_used->eval_flags = orig_flags;
return FAIL;
+ }
/*
* Check for the ":".
***************
*** 2178,2183 ****
--- 2181,2187 ----
emsg(_(e_missing_colon));
if (evaluate && result)
clear_tv(rettv);
+ evalarg_used->eval_flags = orig_flags;
return FAIL;
}
if (getnext)
***************
*** 2188,2193 ****
--- 2192,2198 ----
{
error_white_both(p, 1);
clear_tv(rettv);
+ evalarg_used->eval_flags = orig_flags;
return FAIL;
}
*arg = p;
***************
*** 2200,2205 ****
--- 2205,2211 ----
{
error_white_both(p, 1);
clear_tv(rettv);
+ evalarg_used->eval_flags = orig_flags;
return FAIL;
}
*arg = skipwhite_and_linebreak(*arg + 1, evalarg_used);
***************
*** 2209,2214 ****
--- 2215,2221 ----
{
if (evaluate && result)
clear_tv(rettv);
+ evalarg_used->eval_flags = orig_flags;
return FAIL;
}
if (evaluate && !result)
*** ../vim-8.2.1511/src/testdir/test_vimscript.vim 2020-08-13
19:19:59.917998219 +0200
--- src/testdir/test_vimscript.vim 2020-08-22 22:18:12.484805798 +0200
***************
*** 7445,7450 ****
--- 7445,7474 ----
call StopVimInTerminal(buf)
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
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
*** ../vim-8.2.1511/src/testdir/test_vim9_expr.vim 2020-08-21
22:36:43.666719887 +0200
--- src/testdir/test_vim9_expr.vim 2020-08-22 22:36:01.025350160 +0200
***************
*** 114,119 ****
--- 114,140 ----
let var = v:true ? 1 :2
END
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
func Test_expr1_fails()
*** ../vim-8.2.1511/src/version.c 2020-08-22 21:08:40.756880896 +0200
--- src/version.c 2020-08-22 21:43:20.615229371 +0200
***************
*** 756,757 ****
--- 756,759 ----
{ /* Add new patch number below this line */
+ /**/
+ 1512,
/**/
--
hundred-and-one symptoms of being an internet addict:
269. You receive an e-mail from the wife of a deceased president, offering
to send you twenty million dollar, and you are not even surprised.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202008222037.07MKbsJw811416%40masaka.moolenaar.net.