To: vim_dev@googlegroups.com Subject: Patch 8.2.4914 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4914 Problem: String interpolation in :def function may fail. Solution: Do not terminate the expression. (closes #10377) Files: src/vim9compile.c, src/testdir/test_vim9_expr.vim *** ../vim-8.2.4913/src/vim9compile.c 2022-05-07 10:03:23.998384621 +0100 --- src/vim9compile.c 2022-05-08 16:35:13.696083091 +0100 *************** *** 981,987 **** { char_u *p = str; char_u *val; - char_u save_c; int count = 0; if (cctx->ctx_skip == SKIP_YES) --- 981,986 ---- *************** *** 1051,1061 **** semsg(_(e_missing_close_curly_str), str); return FAIL; } - save_c = *block_end; - *block_end = NUL; if (compile_expr0(&block_start, cctx) == FAIL) return FAIL; - *block_end = save_c; may_generate_2STRING(-1, TRUE, cctx); ++count; --- 1050,1057 ---- *** ../vim-8.2.4913/src/testdir/test_vim9_expr.vim 2022-05-07 10:59:59.563615298 +0100 --- src/testdir/test_vim9_expr.vim 2022-05-08 16:34:41.528106618 +0100 *************** *** 2143,2148 **** --- 2143,2161 ---- v9.CheckDefAndScriptFailure(['var x = "abc'], 'E114:', 1) v9.CheckDefAndScriptFailure(["var x = 'abc"], 'E115:', 1) v9.CheckDefFailure(["if 0", "echo 'xx", "endif"], 'E115', 2) + + # interpolated string + var val = 'val' + var vv = $"some {val}" + assert_equal('some val', vv) + vv = $'other {val}' + assert_equal('other val', vv) + + var x = 'x' + var vl = 'foo xxx bar xxx baz' + ->split($'x{x}x') + ->map((_, v: string) => v =~ 'bar') + assert_equal([false, true, false], vl) enddef def Test_expr8_vimvar() *** ../vim-8.2.4913/src/version.c 2022-05-08 14:59:40.875968914 +0100 --- src/version.c 2022-05-08 16:22:19.392684702 +0100 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 4914, /**/ -- hundred-and-one symptoms of being an internet addict: 137. You decide to stay in college for an additional year or two, just so you can have the free Internet access. /// 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 ///