forked from aniani/vim
patch 8.2.1840: Vim9: error message is not clear about compilation error
Problem: Vim9: error message is not clear about compilation error. Solution: Say "compiling" instead of "processing".
This commit is contained in:
@@ -288,6 +288,9 @@ EXTERN garray_T exestack INIT5(0, 0, sizeof(estack_T), 50, NULL);
|
|||||||
#define SOURCING_LNUM (((estack_T *)exestack.ga_data)[exestack.ga_len - 1].es_lnum)
|
#define SOURCING_LNUM (((estack_T *)exestack.ga_data)[exestack.ga_len - 1].es_lnum)
|
||||||
|
|
||||||
#ifdef FEAT_EVAL
|
#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 ex_nesting_level INIT(= 0); // nesting level
|
||||||
EXTERN int debug_break_level INIT(= -1); // break below this level
|
EXTERN int debug_break_level INIT(= -1); // break below this level
|
||||||
EXTERN int debug_did_msg INIT(= FALSE); // did "debug mode" message
|
EXTERN int debug_did_msg INIT(= FALSE); // did "debug mode" message
|
||||||
|
@@ -467,7 +467,12 @@ get_emsg_source(void)
|
|||||||
if (sname == NULL)
|
if (sname == NULL)
|
||||||
sname = SOURCING_NAME;
|
sname = SOURCING_NAME;
|
||||||
|
|
||||||
p = (char_u *)_("Error detected while processing %s:");
|
#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));
|
Buf = alloc(STRLEN(sname) + STRLEN(p));
|
||||||
if (Buf != NULL)
|
if (Buf != NULL)
|
||||||
sprintf((char *)Buf, (char *)p, sname);
|
sprintf((char *)Buf, (char *)p, sname);
|
||||||
|
@@ -13,6 +13,38 @@ func Test_def_basic()
|
|||||||
call SomeFunc()->assert_equal('yes')
|
call SomeFunc()->assert_equal('yes')
|
||||||
endfunc
|
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
|
def ReturnString(): string
|
||||||
return 'string'
|
return 'string'
|
||||||
enddef
|
enddef
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1840,
|
||||||
/**/
|
/**/
|
||||||
1839,
|
1839,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -6715,6 +6715,7 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
|
|||||||
int called_emsg_before = called_emsg;
|
int called_emsg_before = called_emsg;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
sctx_T save_current_sctx = current_sctx;
|
sctx_T save_current_sctx = current_sctx;
|
||||||
|
int save_estack_compiling = estack_compiling;
|
||||||
int do_estack_push;
|
int do_estack_push;
|
||||||
int emsg_before = called_emsg;
|
int emsg_before = called_emsg;
|
||||||
int new_def_function = FALSE;
|
int new_def_function = FALSE;
|
||||||
@@ -6757,6 +6758,7 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
|
|||||||
do_estack_push = !estack_top_is_ufunc(ufunc, 1);
|
do_estack_push = !estack_top_is_ufunc(ufunc, 1);
|
||||||
if (do_estack_push)
|
if (do_estack_push)
|
||||||
estack_push_ufunc(ufunc, 1);
|
estack_push_ufunc(ufunc, 1);
|
||||||
|
estack_compiling = TRUE;
|
||||||
|
|
||||||
if (ufunc->uf_def_args.ga_len > 0)
|
if (ufunc->uf_def_args.ga_len > 0)
|
||||||
{
|
{
|
||||||
@@ -7303,6 +7305,7 @@ erret:
|
|||||||
}
|
}
|
||||||
|
|
||||||
current_sctx = save_current_sctx;
|
current_sctx = save_current_sctx;
|
||||||
|
estack_compiling = save_estack_compiling;
|
||||||
if (do_estack_push)
|
if (do_estack_push)
|
||||||
estack_pop();
|
estack_pop();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user