To: vim_dev@googlegroups.com Subject: Patch 8.2.0583 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0583 Problem: Vim9: # comment not recognized in :def function. Solution: Recognize and skip # comment. Files: src/vim9compile.c, src/testdir/test_vim9_script.vim *** ../vim-8.2.0582/src/vim9compile.c 2020-04-14 20:15:45.288566185 +0200 --- src/vim9compile.c 2020-04-16 12:59:37.019863531 +0200 *************** *** 5772,5778 **** */ for (;;) { ! int is_ex_command; // Bail out on the first error to avoid a flood of errors and report // the right line number when inside try/catch. --- 5772,5778 ---- */ for (;;) { ! int is_ex_command = FALSE; // Bail out on the first error to avoid a flood of errors and report // the right line number when inside try/catch. *************** *** 5791,5796 **** --- 5791,5797 ---- { line = next_line_from_context(&cctx); if (cctx.ctx_lnum >= ufunc->uf_lines.ga_len) + // beyond the last line break; } emsg_before = called_emsg; *************** *** 5800,5834 **** ea.cmdlinep = &line; ea.cmd = skipwhite(line); ! // "}" ends a block scope ! if (*ea.cmd == '}') { ! scopetype_T stype = cctx.ctx_scope == NULL ! ? NO_SCOPE : cctx.ctx_scope->se_type; ! if (stype == BLOCK_SCOPE) ! { ! compile_endblock(&cctx); ! line = ea.cmd; ! } ! else ! { ! emsg(_("E1025: using } outside of a block scope")); ! goto erret; ! } ! if (line != NULL) ! line = skipwhite(ea.cmd + 1); ! continue; ! } ! // "{" starts a block scope ! // "{'a': 1}->func() is something else ! if (*ea.cmd == '{' && ends_excmd(*skipwhite(ea.cmd + 1))) ! { ! line = compile_block(ea.cmd, &cctx); ! continue; } - is_ex_command = *ea.cmd == ':'; /* * COMMAND MODIFIERS --- 5801,5853 ---- ea.cmdlinep = &line; ea.cmd = skipwhite(line); ! // Some things can be recognized by the first character. ! switch (*ea.cmd) { ! case '#': ! // "#" starts a comment, but not "#{". ! if (ea.cmd[1] != '{') ! { ! line = (char_u *)""; ! continue; ! } ! break; ! case '}': ! { ! // "}" ends a block scope ! scopetype_T stype = cctx.ctx_scope == NULL ! ? NO_SCOPE : cctx.ctx_scope->se_type; ! ! if (stype == BLOCK_SCOPE) ! { ! compile_endblock(&cctx); ! line = ea.cmd; ! } ! else ! { ! emsg(_("E1025: using } outside of a block scope")); ! goto erret; ! } ! if (line != NULL) ! line = skipwhite(ea.cmd + 1); ! continue; ! } ! ! case '{': ! // "{" starts a block scope ! // "{'a': 1}->func() is something else ! if (ends_excmd(*skipwhite(ea.cmd + 1))) ! { ! line = compile_block(ea.cmd, &cctx); ! continue; ! } ! break; ! case ':': ! is_ex_command = TRUE; ! break; } /* * COMMAND MODIFIERS *** ../vim-8.2.0582/src/testdir/test_vim9_script.vim 2020-04-13 17:20:56.174130307 +0200 --- src/testdir/test_vim9_script.vim 2020-04-16 12:49:19.613658293 +0200 *************** *** 63,71 **** let Funky2: func = function('len') let Party2: func = funcref('Test_syntax') ! " type becomes list let somelist = rand() > 0 ? [1, 2, 3] : ['a', 'b', 'c'] ! " type becomes dict let somedict = rand() > 0 ? #{a: 1, b: 2} : #{a: 'a', b: 'b'} g:newvar = 'new' --- 63,71 ---- let Funky2: func = function('len') let Party2: func = funcref('Test_syntax') ! # type becomes list let somelist = rand() > 0 ? [1, 2, 3] : ['a', 'b', 'c'] ! # type becomes dict let somedict = rand() > 0 ? #{a: 1, b: 2} : #{a: 'a', b: 'b'} g:newvar = 'new' *************** *** 104,110 **** call CheckDefFailure(['¬ex += 3'], 'E113:') call CheckDefFailure(['&ts ..= "xxx"'], 'E1019:') call CheckDefFailure(['&path += 3'], 'E1013:') ! " test freeing ISN_STOREOPT call CheckDefFailure(['&ts = 3', 'let asdf'], 'E1022:') &ts = 8 --- 104,110 ---- call CheckDefFailure(['¬ex += 3'], 'E113:') call CheckDefFailure(['&ts ..= "xxx"'], 'E1019:') call CheckDefFailure(['&path += 3'], 'E1013:') ! # test freeing ISN_STOREOPT call CheckDefFailure(['&ts = 3', 'let asdf'], 'E1022:') &ts = 8 *************** *** 131,137 **** def Test_assignment_default() ! " Test default values. let thebool: bool assert_equal(v:false, thebool) --- 131,137 ---- def Test_assignment_default() ! # Test default values. let thebool: bool assert_equal(v:false, thebool) *** ../vim-8.2.0582/src/version.c 2020-04-15 21:44:08.062129755 +0200 --- src/version.c 2020-04-16 12:48:34.109800559 +0200 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 583, /**/ -- Mrs Abbott: I'm a paediatrician. Basil: Feet? Mrs Abbott: Children. Sybil: Oh, Basil! Basil: Well, children have feet, don't they? That's how they move around, my dear. You must take a look next time, it's most interesting. (Fawlty Towers) /// 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 ///