To: vim_dev@googlegroups.com Subject: Patch 8.2.3239 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3239 Problem: Vim9: no error using heredoc for a number variable. Solution: Add a type check. (closes #8627) Files: src/vim9compile.c, src/evalvars.c, src/testdir/test_vim9_assign.vim *** ../vim-8.2.3238/src/vim9compile.c 2021-07-28 20:52:08.681166840 +0200 --- src/vim9compile.c 2021-07-28 21:21:53.673114652 +0200 *************** *** 6875,6881 **** if (compile_assign_lhs(var_start, &lhs, cmdidx, is_decl, heredoc, oplen, cctx) == FAIL) goto theend; ! if (!heredoc) { if (cctx->ctx_skip == SKIP_YES) { --- 6875,6889 ---- if (compile_assign_lhs(var_start, &lhs, cmdidx, is_decl, heredoc, oplen, cctx) == FAIL) goto theend; ! if (heredoc) ! { ! SOURCING_LNUM = start_lnum; ! if (lhs.lhs_has_type ! && need_type(&t_list_string, lhs.lhs_type, ! -1, 0, cctx, FALSE, FALSE) == FAIL) ! goto theend; ! } ! else { if (cctx->ctx_skip == SKIP_YES) { *** ../vim-8.2.3238/src/evalvars.c 2021-07-25 14:13:50.040566339 +0200 --- src/evalvars.c 2021-07-28 21:24:25.432779014 +0200 *************** *** 817,822 **** --- 817,823 ---- else if (expr[0] == '=' && expr[1] == '<' && expr[2] == '<') { list_T *l; + long cur_lnum = SOURCING_LNUM; // HERE document l = heredoc_get(eap, expr + 3, FALSE); *************** *** 825,830 **** --- 826,833 ---- rettv_list_set(&rettv, l); if (!eap->skip) { + // errors are for the assignment, not the end marker + SOURCING_LNUM = cur_lnum; op[0] = '='; op[1] = NUL; (void)ex_let_vars(eap->arg, &rettv, FALSE, semicolon, var_count, *** ../vim-8.2.3238/src/testdir/test_vim9_assign.vim 2021-07-28 19:34:10.559082899 +0200 --- src/testdir/test_vim9_assign.vim 2021-07-28 21:20:53.465248260 +0200 *************** *** 1392,1397 **** --- 1392,1405 ---- [END] CheckScriptFailure(lines, 'E1145: Missing heredoc end marker: END') delfunc! g:Func + + lines =<< trim END + var lines: number =<< trim STOP + aaa + bbb + STOP + END + CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected number but got list', 1) enddef def Test_var_func_call() *** ../vim-8.2.3238/src/version.c 2021-07-28 20:52:08.681166840 +0200 --- src/version.c 2021-07-28 21:16:44.765803934 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3239, /**/ -- ARTHUR: This new learning amazes me, Sir Bedevere. Explain again how sheep's bladders may be employed to prevent earthquakes. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// 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 ///