To: vim_dev@googlegroups.com Subject: Patch 8.2.0216 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0216 Problem: Several Vim9 instructions are not tested. Solution: Add more tests. Fix :disassamble output. Make catch with pattern work. Files: src/testdir/test_vim9_script.vim, src/vim9execute.c, src/vim9compile.c *** ../vim-8.2.0215/src/testdir/test_vim9_script.vim 2020-02-04 21:54:03.277158742 +0100 --- src/testdir/test_vim9_script.vim 2020-02-05 22:07:14.508076292 +0100 *************** *** 474,479 **** --- 474,488 ---- echo @z enddef + def s:ScriptFuncPush() + let localbool = true + let localspec = v:none + let localblob = 0z1234 + if has('float') + let localfloat = 1.234 + endif + enddef + def s:ScriptFuncStore() let localnr = 1 localnr = 2 *************** *** 487,492 **** --- 496,511 ---- @z = 'rv' enddef + def s:ScriptFuncTry() + try + echo 'yes' + catch /fail/ + echo 'no' + finally + echo 'end' + endtry + enddef + def Test_disassemble() assert_fails('disass NoFunc', 'E1061:') assert_fails('disass NotCompiled', 'E1062:') *************** *** 504,512 **** \ .. ' LOADREG @z.*' \, res) ! " TODO: ! " v:char = ! " s:scriptvar = res = execute('disass s:ScriptFuncStore') assert_match('\d*_ScriptFuncStore.*' \ .. 'localnr = 2.*' --- 523,544 ---- \ .. ' LOADREG @z.*' \, res) ! res = execute('disass s:ScriptFuncPush') ! assert_match('\d*_ScriptFuncPush.*' ! \ .. 'localbool = true.*' ! \ .. ' PUSH v:true.*' ! \ .. 'localspec = v:none.*' ! \ .. ' PUSH v:none.*' ! \ .. 'localblob = 0z1234.*' ! \ .. ' PUSHBLOB 0z1234.*' ! \, res) ! if has('float') ! assert_match('\d*_ScriptFuncPush.*' ! \ .. 'localfloat = 1.234.*' ! \ .. ' PUSHF 1.234.*' ! \, res) ! endif ! res = execute('disass s:ScriptFuncStore') assert_match('\d*_ScriptFuncStore.*' \ .. 'localnr = 2.*' *************** *** 526,531 **** --- 558,580 ---- \ .. '@z = ''rv''.*' \ .. ' STOREREG @z.*' \, res) + + res = execute('disass s:ScriptFuncTry') + assert_match('\d*_ScriptFuncTry.*' + \ .. 'try.*' + \ .. 'TRY catch -> \d\+, finally -> \d\+.*' + \ .. 'catch /fail/.*' + \ .. ' JUMP -> \d\+.*' + \ .. ' PUSH v:exception.*' + \ .. ' PUSHS "fail".*' + \ .. ' COMPARESTRING =\~.*' + \ .. ' JUMP_IF_FALSE -> \d\+.*' + \ .. ' CATCH.*' + \ .. 'finally.*' + \ .. ' PUSHS "end".*' + \ .. 'endtry.*' + \ .. ' ENDTRY.*' + \, res) enddef *** ../vim-8.2.0215/src/vim9execute.c 2020-02-04 21:24:11.702500431 +0100 --- src/vim9execute.c 2020-02-05 21:33:55.607069675 +0100 *************** *** 1726,1732 **** char_u *tofree; r = blob2string(iptr->isn_arg.blob, &tofree, numbuf); ! smsg("%4d PUSHBLOB \"%s\"", current, r); vim_free(tofree); } break; --- 1726,1732 ---- char_u *tofree; r = blob2string(iptr->isn_arg.blob, &tofree, numbuf); ! smsg("%4d PUSHBLOB %s", current, r); vim_free(tofree); } break; *** ../vim-8.2.0215/src/vim9compile.c 2020-02-04 23:08:11.081794687 +0100 --- src/vim9compile.c 2020-02-05 21:57:25.724308663 +0100 *************** *** 4369,4381 **** } else { // Push v:exception, push {expr} and MATCH generate_instr_type(cctx, ISN_PUSHEXC, &t_string); ! if (compile_expr1(&p, cctx) == FAIL) ! return NULL; - // TODO: check for strings? if (generate_COMPARE(cctx, EXPR_MATCH, FALSE) == FAIL) return NULL; --- 4369,4401 ---- } else { + char_u *end; + char_u *pat; + char_u *tofree = NULL; + size_t len; + // Push v:exception, push {expr} and MATCH generate_instr_type(cctx, ISN_PUSHEXC, &t_string); ! end = skip_regexp(p + 1, *p, TRUE, &tofree); ! if (*end != *p) ! { ! semsg(_("E1067: Separator mismatch: %s"), p); ! vim_free(tofree); ! return FAIL; ! } ! if (tofree == NULL) ! len = end - (p + 1); ! else ! len = end - (tofree + 1); ! pat = vim_strnsave(p + 1, len); ! vim_free(tofree); ! p += len + 2; ! if (pat == NULL) ! return FAIL; ! if (generate_PUSHS(cctx, pat) == FAIL) ! return FAIL; if (generate_COMPARE(cctx, EXPR_MATCH, FALSE) == FAIL) return NULL; *** ../vim-8.2.0215/src/version.c 2020-02-05 21:13:57.296873717 +0100 --- src/version.c 2020-02-05 21:31:50.499670854 +0100 *************** *** 744,745 **** --- 744,747 ---- { /* Add new patch number below this line */ + /**/ + 216, /**/ -- My sister Cecilia opened a computer store in Hawaii. She sells C shells by the seashore. /// Bram Moolenaar -- Bram@Moolenaar.net -- 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 ///