To: vim_dev@googlegroups.com Subject: Patch 8.2.3161 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3161 Problem: Vim9: no error when reltime() has invalid arguments. Solution: Add an error. (closes #8562) Files: src/time.c, src/testdir/test_vim9_builtin.vim *** ../vim-8.2.3160/src/time.c 2021-06-02 13:28:11.439120443 +0200 --- src/time.c 2021-07-14 20:50:20.889778521 +0200 *************** *** 178,184 **** --- 178,188 ---- else if (argvars[1].v_type == VAR_UNKNOWN) { if (list2proftime(&argvars[0], &res) == FAIL) + { + if (in_vim9script()) + emsg(_(e_invarg)); return; + } profile_end(&res); } else *************** *** 186,192 **** --- 190,200 ---- // Two arguments: compute the difference. if (list2proftime(&argvars[0], &start) == FAIL || list2proftime(&argvars[1], &res) == FAIL) + { + if (in_vim9script()) + emsg(_(e_invarg)); return; + } profile_sub(&res, &start); } *************** *** 223,228 **** --- 231,238 ---- # ifdef FEAT_RELTIME if (list2proftime(&argvars[0], &tm) == OK) rettv->vval.v_float = profile_float(&tm); + else if (in_vim9script()) + emsg(_(e_invarg)); # endif } # endif *************** *** 242,247 **** --- 252,259 ---- # ifdef FEAT_RELTIME if (list2proftime(&argvars[0], &tm) == OK) rettv->vval.v_string = vim_strsave((char_u *)profile_msg(&tm)); + else if (in_vim9script()) + emsg(_(e_invarg)); # endif } *** ../vim-8.2.3160/src/testdir/test_vim9_builtin.vim 2021-07-12 22:15:20.950777281 +0200 --- src/testdir/test_vim9_builtin.vim 2021-07-14 20:49:42.309814504 +0200 *************** *** 1652,1657 **** --- 1652,1662 ---- enddef def Test_reltime() + CheckFeature reltime + + CheckDefExecAndScriptFailure(['[]->reltime()'], 'E474:') + CheckDefExecAndScriptFailure(['[]->reltime([])'], 'E474:') + CheckDefFailure(['reltime("x")'], 'E1013: Argument 1: type mismatch, expected list but got string') CheckDefFailure(['reltime(["x", "y"])'], 'E1013: Argument 1: type mismatch, expected list but got list') CheckDefFailure(['reltime([1, 2], 10)'], 'E1013: Argument 2: type mismatch, expected list but got number') *************** *** 1663,1674 **** --- 1668,1687 ---- enddef def Test_reltimefloat() + CheckFeature reltime + + CheckDefExecAndScriptFailure(['[]->reltimefloat()'], 'E474:') + CheckDefFailure(['reltimefloat("x")'], 'E1013: Argument 1: type mismatch, expected list but got string') CheckDefFailure(['reltimefloat([1.1])'], 'E1013: Argument 1: type mismatch, expected list but got list') assert_true(type(reltimefloat(reltime())) == v:t_float) enddef def Test_reltimestr() + CheckFeature reltime + + CheckDefExecAndScriptFailure(['[]->reltimestr()'], 'E474:') + CheckDefFailure(['reltimestr(true)'], 'E1013: Argument 1: type mismatch, expected list but got bool') CheckDefFailure(['reltimestr([true])'], 'E1013: Argument 1: type mismatch, expected list but got list') assert_true(type(reltimestr(reltime())) == v:t_string) *** ../vim-8.2.3160/src/version.c 2021-07-14 20:00:24.545690127 +0200 --- src/version.c 2021-07-14 21:00:20.221106793 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3161, /**/ -- Amazing but true: If all the salmon caught in Canada in one year were laid end to end across the Sahara Desert, the smell would be absolutely awful. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///