To: vim_dev@googlegroups.com Subject: Patch 8.2.1840 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1840 Problem: Vim9: error message is not clear about compilation error. Solution: Say "compiling" instead of "processing". Files: src/vim9compile.c, src/message.c, src/globals.h, src/testdir/test_vim9_func.vim *** ../vim-8.2.1839/src/vim9compile.c 2020-10-09 22:04:25.210842991 +0200 --- src/vim9compile.c 2020-10-12 21:29:19.653072744 +0200 *************** *** 6715,6720 **** --- 6715,6721 ---- int called_emsg_before = called_emsg; int ret = FAIL; sctx_T save_current_sctx = current_sctx; + int save_estack_compiling = estack_compiling; int do_estack_push; int emsg_before = called_emsg; int new_def_function = FALSE; *************** *** 6757,6762 **** --- 6758,6764 ---- do_estack_push = !estack_top_is_ufunc(ufunc, 1); if (do_estack_push) estack_push_ufunc(ufunc, 1); + estack_compiling = TRUE; if (ufunc->uf_def_args.ga_len > 0) { *************** *** 7303,7308 **** --- 7305,7311 ---- } current_sctx = save_current_sctx; + estack_compiling = save_estack_compiling; if (do_estack_push) estack_pop(); *** ../vim-8.2.1839/src/message.c 2020-09-10 19:25:01.612194701 +0200 --- src/message.c 2020-10-12 21:32:31.272527001 +0200 *************** *** 467,473 **** if (sname == NULL) sname = SOURCING_NAME; ! p = (char_u *)_("Error detected while processing %s:"); Buf = alloc(STRLEN(sname) + STRLEN(p)); if (Buf != NULL) sprintf((char *)Buf, (char *)p, sname); --- 467,478 ---- if (sname == NULL) sname = SOURCING_NAME; ! #ifdef FEAT_EVAL ! if (estack_compiling) ! p = (char_u *)_("Error detected while compiling %s:"); ! else ! #endif ! p = (char_u *)_("Error detected while processing %s:"); Buf = alloc(STRLEN(sname) + STRLEN(p)); if (Buf != NULL) sprintf((char *)Buf, (char *)p, sname); *** ../vim-8.2.1839/src/globals.h 2020-09-28 22:29:25.425766287 +0200 --- src/globals.h 2020-10-12 21:32:41.392498144 +0200 *************** *** 288,293 **** --- 288,296 ---- #define SOURCING_LNUM (((estack_T *)exestack.ga_data)[exestack.ga_len - 1].es_lnum) #ifdef FEAT_EVAL + // whether inside compile_def_function() + EXTERN int estack_compiling INIT(= FALSE); + EXTERN int ex_nesting_level INIT(= 0); // nesting level EXTERN int debug_break_level INIT(= -1); // break below this level EXTERN int debug_did_msg INIT(= FALSE); // did "debug mode" message *** ../vim-8.2.1839/src/testdir/test_vim9_func.vim 2020-10-10 14:12:58.024646147 +0200 --- src/testdir/test_vim9_func.vim 2020-10-12 22:05:50.507556439 +0200 *************** *** 13,18 **** --- 13,50 ---- call SomeFunc()->assert_equal('yes') endfunc + def Test_compiling_error() + # use a terminal to see the whole error message + CheckRunVimInTerminal + + var lines =<< trim END + vim9script + def Fails() + echo nothing + enddef + defcompile + END + call writefile(lines, 'XTest_compile_error') + var buf = RunVimInTerminal('-S XTest_compile_error', + #{rows: 10, wait_for_ruler: 0}) + var text = '' + for loop in range(100) + text = '' + for i in range(1, 9) + text ..= term_getline(buf, i) + endfor + if text =~ 'Error detected' + break + endif + sleep 20m + endfor + assert_match('Error detected while compiling command line.*Fails.*Variable not found: nothing', text) + + # clean up + call StopVimInTerminal(buf) + call delete('XTest_compile_error') + enddef + def ReturnString(): string return 'string' enddef *** ../vim-8.2.1839/src/version.c 2020-10-12 20:31:11.291727542 +0200 --- src/version.c 2020-10-12 22:06:21.083488322 +0200 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 1840, /**/ -- hundred-and-one symptoms of being an internet addict: 79. All of your most erotic dreams have a scrollbar at the right side. /// 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 ///