Patch 8.2.0336

14 views
Skip to first unread message

Bram Moolenaar

unread,
Feb 29, 2020, 5:25:18 PM2/29/20
to vim...@googlegroups.com

Patch 8.2.0336
Problem: Vim9: insufficient test coverage for compiling.
Solution: Add more tests.
Files: src/testdir/test_vim9_expr.vim, src/testdir/test_vim9_script.vim,
src/vim9.h, src/vim9compile.c, src/vim9execute.c


*** ../vim-8.2.0335/src/testdir/test_vim9_expr.vim 2020-02-25 22:58:25.607851771 +0100
--- src/testdir/test_vim9_expr.vim 2020-02-29 22:22:13.168702876 +0100
***************
*** 9,14 ****
--- 9,20 ----
call delete('Xdef')
endfunc

+ func CheckDefFailureMult(lines, error)
+ call writefile(['def! Func()'] + a:lines + ['enddef'], 'Xdef')
+ call assert_fails('so Xdef', a:error, join(a:lines, ' | '))
+ call delete('Xdef')
+ endfunc
+
" Check that "line" inside ":def" results in an "error" message when executed.
func CheckDefExecFailure(line, error)
call writefile(['def! Func()', a:line, 'enddef'], 'Xdef')
***************
*** 805,810 ****
--- 811,818 ----
call CheckDefExecFailure("let x = +g:ablob", 'E974:')
call CheckDefExecFailure("let x = +g:alist", 'E745:')
call CheckDefExecFailure("let x = +g:adict", 'E728:')
+
+ call CheckDefFailureMult(["let x = ''", "let y = x.memb"], 'E715:')
endfunc

let g:Funcrefs = [function('add')]
*** ../vim-8.2.0335/src/testdir/test_vim9_script.vim 2020-02-26 21:24:19.157582116 +0100
--- src/testdir/test_vim9_script.vim 2020-02-29 23:21:32.797060169 +0100
***************
*** 53,58 ****
--- 53,62 ----
let dict4: dict<any> = #{one: 1, two: '2'}
let dict5: dict<blob> = #{one: 0z01, tw: 0z02}

+ if has('channel')
+ let chan1: channel
+ endif
+
g:newvar = 'new'
assert_equal('new', g:newvar)

***************
*** 91,96 ****
--- 95,115 ----

call CheckDefFailure(['let var = feedkeys("0")'], 'E1031:')
call CheckDefFailure(['let var: number = feedkeys("0")'], 'expected number but got void')
+
+ call CheckDefFailure(['let var: dict <number>'], 'E1007:')
+ call CheckDefFailure(['let var: dict<number'], 'E1009:')
+
+ call CheckDefFailure(['let var: ally'], 'E1010:')
+ call CheckDefFailure(['let var: bram'], 'E1010:')
+ call CheckDefFailure(['let var: cathy'], 'E1010:')
+ call CheckDefFailure(['let var: dom'], 'E1010:')
+ call CheckDefFailure(['let var: freddy'], 'E1010:')
+ call CheckDefFailure(['let var: john'], 'E1010:')
+ call CheckDefFailure(['let var: larry'], 'E1010:')
+ call CheckDefFailure(['let var: ned'], 'E1010:')
+ call CheckDefFailure(['let var: pam'], 'E1010:')
+ call CheckDefFailure(['let var: sam'], 'E1010:')
+ call CheckDefFailure(['let var: vim'], 'E1010:')
endfunc

func Test_const()
***************
*** 203,208 ****
--- 222,233 ----
assert_equal('one,two,three', MyDefVarargs('one', 'two', 'three'))
enddef

+ def Test_using_var_as_arg()
+ call writefile(['def Func(x: number)', 'let x = 234', 'enddef'], 'Xdef')
+ call assert_fails('so Xdef', 'E1006:')
+ call delete('Xdef')
+ enddef
+
def Test_call_func_defined_later()
call assert_equal('one', DefinedLater('one'))
call assert_fails('call NotDefined("one")', 'E117:')
*** ../vim-8.2.0335/src/vim9.h 2020-02-26 18:23:39.554650851 +0100
--- src/vim9.h 2020-02-29 22:52:13.841370416 +0100
***************
*** 39,52 ****
ISN_STORENR, // store number into local variable isn_arg.storenr.str_idx

// constants
! ISN_PUSHNR, // push number isn_arg.number
! ISN_PUSHBOOL, // push bool value isn_arg.number
! ISN_PUSHSPEC, // push special value isn_arg.number
! ISN_PUSHF, // push float isn_arg.fnumber
! ISN_PUSHS, // push string isn_arg.string
! ISN_PUSHBLOB, // push blob isn_arg.blob
! ISN_NEWLIST, // push list from stack items, size is isn_arg.number
! ISN_NEWDICT, // push dict from stack items, size is isn_arg.number

// function call
ISN_BCALL, // call builtin function isn_arg.bfunc
--- 39,56 ----
ISN_STORENR, // store number into local variable isn_arg.storenr.str_idx

// constants
! ISN_PUSHNR, // push number isn_arg.number
! ISN_PUSHBOOL, // push bool value isn_arg.number
! ISN_PUSHSPEC, // push special value isn_arg.number
! ISN_PUSHF, // push float isn_arg.fnumber
! ISN_PUSHS, // push string isn_arg.string
! ISN_PUSHBLOB, // push blob isn_arg.blob
! ISN_PUSHFUNC, // push func isn_arg.string
! ISN_PUSHPARTIAL, // push partial ?
! ISN_PUSHCHANNEL, // push channel isn_arg.channel
! ISN_PUSHJOB, // push channel isn_arg.job
! ISN_NEWLIST, // push list from stack items, size is isn_arg.number
! ISN_NEWDICT, // push dict from stack items, size is isn_arg.number

// function call
ISN_BCALL, // call builtin function isn_arg.bfunc
***************
*** 209,214 ****
--- 213,220 ----
#ifdef FEAT_FLOAT
float_T fnumber;
#endif
+ channel_T *channel;
+ job_T *job;
jump_T jump;
forloop_T forloop;
try_T try;
*** ../vim-8.2.0335/src/vim9compile.c 2020-02-26 20:15:14.944051070 +0100
--- src/vim9compile.c 2020-02-29 23:08:29.375281670 +0100
***************
*** 642,647 ****
--- 642,679 ----
}

/*
+ * Generate an ISN_PUSHCHANNEL instruction.
+ * Consumes "channel".
+ */
+ static int
+ generate_PUSHCHANNEL(cctx_T *cctx, channel_T *channel)
+ {
+ isn_T *isn;
+
+ if ((isn = generate_instr_type(cctx, ISN_PUSHCHANNEL, &t_channel)) == NULL)
+ return FAIL;
+ isn->isn_arg.channel = channel;
+
+ return OK;
+ }
+
+ /*
+ * Generate an ISN_PUSHJOB instruction.
+ * Consumes "job".
+ */
+ static int
+ generate_PUSHJOB(cctx_T *cctx, job_T *job)
+ {
+ isn_T *isn;
+
+ if ((isn = generate_instr_type(cctx, ISN_PUSHCHANNEL, &t_channel)) == NULL)
+ return FAIL;
+ isn->isn_arg.job = job;
+
+ return OK;
+ }
+
+ /*
* Generate an ISN_PUSHBLOB instruction.
* Consumes "blob".
*/
***************
*** 658,663 ****
--- 690,711 ----
}

/*
+ * Generate an ISN_PUSHFUNC instruction with name "name".
+ * Consumes "name".
+ */
+ static int
+ generate_PUSHFUNC(cctx_T *cctx, char_u *name)
+ {
+ isn_T *isn;
+
+ if ((isn = generate_instr_type(cctx, ISN_PUSHFUNC, &t_func_void)) == NULL)
+ return FAIL;
+ isn->isn_arg.string = name;
+
+ return OK;
+ }
+
+ /*
* Generate an ISN_STORE instruction.
*/
static int
***************
*** 3549,3558 ****
generate_PUSHBLOB(cctx, NULL);
break;
case VAR_FUNC:
! // generate_PUSHS(cctx, NULL); TODO
break;
case VAR_PARTIAL:
! // generate_PUSHS(cctx, NULL); TODO
break;
case VAR_LIST:
generate_NEWLIST(cctx, 0);
--- 3597,3607 ----
generate_PUSHBLOB(cctx, NULL);
break;
case VAR_FUNC:
! generate_PUSHFUNC(cctx, NULL);
break;
case VAR_PARTIAL:
! // generate_PUSHPARTIAL(cctx, NULL);
! emsg("Partial type not supported yet");
break;
case VAR_LIST:
generate_NEWLIST(cctx, 0);
***************
*** 3561,3570 ****
generate_NEWDICT(cctx, 0);
break;
case VAR_JOB:
! // generate_PUSHS(cctx, NULL); TODO
break;
case VAR_CHANNEL:
! // generate_PUSHS(cctx, NULL); TODO
break;
case VAR_NUMBER:
case VAR_UNKNOWN:
--- 3610,3619 ----
generate_NEWDICT(cctx, 0);
break;
case VAR_JOB:
! generate_PUSHJOB(cctx, NULL);
break;
case VAR_CHANNEL:
! generate_PUSHCHANNEL(cctx, NULL);
break;
case VAR_NUMBER:
case VAR_UNKNOWN:
***************
*** 4748,4753 ****
--- 4797,4803 ----
int called_emsg_before = called_emsg;
int ret = FAIL;
sctx_T save_current_sctx = current_sctx;
+ int emsg_before = called_emsg;

if (ufunc->uf_dfunc_idx >= 0)
{
***************
*** 4828,4834 ****
++line;
else if (line != NULL && *line != NUL)
{
! semsg(_("E488: Trailing characters: %s"), line);
goto erret;
}
else
--- 4878,4885 ----
++line;
else if (line != NULL && *line != NUL)
{
! if (emsg_before == called_emsg)
! semsg(_("E488: Trailing characters: %s"), line);
goto erret;
}
else
***************
*** 4844,4849 ****
--- 4895,4901 ----
break;
SOURCING_LNUM = ufunc->uf_script_ctx.sc_lnum + cctx.ctx_lnum + 1;
}
+ emsg_before = called_emsg;

had_return = FALSE;
vim_memset(&ea, 0, sizeof(ea));
***************
*** 5153,5158 ****
--- 5205,5211 ----
case ISN_PUSHS:
case ISN_STOREENV:
case ISN_STOREG:
+ case ISN_PUSHFUNC:
vim_free(isn->isn_arg.string);
break;

***************
*** 5169,5174 ****
--- 5222,5239 ----
blob_unref(isn->isn_arg.blob);
break;

+ case ISN_PUSHPARTIAL:
+ // TODO
+ break;
+
+ case ISN_PUSHJOB:
+ job_unref(isn->isn_arg.job);
+ break;
+
+ case ISN_PUSHCHANNEL:
+ channel_unref(isn->isn_arg.channel);
+ break;
+
case ISN_UCALL:
vim_free(isn->isn_arg.ufunc.cuf_name);
break;
*** ../vim-8.2.0335/src/vim9execute.c 2020-02-27 21:48:46.634738617 +0100
--- src/vim9execute.c 2020-02-29 23:19:28.289434771 +0100
***************
*** 840,845 ****
--- 840,849 ----
case ISN_PUSHF:
case ISN_PUSHS:
case ISN_PUSHBLOB:
+ case ISN_PUSHFUNC:
+ case ISN_PUSHPARTIAL:
+ case ISN_PUSHCHANNEL:
+ case ISN_PUSHJOB:
if (ga_grow(&ectx.ec_stack, 1) == FAIL)
goto failed;
tv = STACK_TV_BOT(0);
***************
*** 867,872 ****
--- 871,899 ----
case ISN_PUSHBLOB:
blob_copy(iptr->isn_arg.blob, tv);
break;
+ case ISN_PUSHFUNC:
+ tv->v_type = VAR_FUNC;
+ tv->vval.v_string = vim_strsave(iptr->isn_arg.string);
+ break;
+ case ISN_PUSHPARTIAL:
+ tv->v_type = VAR_UNKNOWN;
+ break;
+ case ISN_PUSHCHANNEL:
+ #ifdef FEAT_JOB_CHANNEL
+ tv->v_type = VAR_CHANNEL;
+ tv->vval.v_channel = iptr->isn_arg.channel;
+ if (tv->vval.v_channel != NULL)
+ ++tv->vval.v_channel->ch_refcount;
+ #endif
+ break;
+ case ISN_PUSHJOB:
+ #ifdef FEAT_JOB_CHANNEL
+ tv->v_type = VAR_JOB;
+ tv->vval.v_job = iptr->isn_arg.job;
+ if (tv->vval.v_job != NULL)
+ ++tv->vval.v_job->jv_refcount;
+ #endif
+ break;
default:
tv->v_type = VAR_STRING;
tv->vval.v_string = vim_strsave(iptr->isn_arg.string);
***************
*** 1846,1851 ****
--- 1873,1908 ----
vim_free(tofree);
}
break;
+ case ISN_PUSHFUNC:
+ smsg("%4d PUSHFUNC \"%s\"", current, iptr->isn_arg.string);
+ break;
+ case ISN_PUSHPARTIAL:
+ // TODO
+ smsg("%4d PUSHPARTIAL", current);
+ break;
+ case ISN_PUSHCHANNEL:
+ #ifdef FEAT_JOB_CHANNEL
+ {
+ channel_T *channel = iptr->isn_arg.channel;
+
+ smsg("%4d PUSHCHANNEL %d", current,
+ channel == NULL ? 0 : channel->ch_id);
+ }
+ #endif
+ break;
+ case ISN_PUSHJOB:
+ #ifdef FEAT_JOB_CHANNEL
+ {
+ typval_T tv;
+ char_u *name;
+
+ tv.v_type = VAR_JOB;
+ tv.vval.v_job = iptr->isn_arg.job;
+ name = tv_get_string(&tv);
+ smsg("%4d PUSHJOB %s", current, name);
+ }
+ #endif
+ break;
case ISN_PUSHEXC:
smsg("%4d PUSH v:exception", current);
break;
*** ../vim-8.2.0335/src/version.c 2020-02-29 22:06:25.647709244 +0100
--- src/version.c 2020-02-29 23:21:50.689005933 +0100
***************
*** 740,741 ****
--- 740,743 ----
{ /* Add new patch number below this line */
+ /**/
+ 336,
/**/

--
hundred-and-one symptoms of being an internet addict:
139. You down your lunch in five minutes, at your desk, so you can
spend the rest of the hour surfing the Net.

/// Bram Moolenaar -- Br...@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 ///

John Marriott

unread,
Feb 29, 2020, 6:04:00 PM2/29/20
to vim...@googlegroups.com

On 01-Mar-2020 09:25, Bram Moolenaar wrote:
> Patch 8.2.0336
> Problem: Vim9: insufficient test coverage for compiling.
> Solution: Add more tests.
> Files: src/testdir/test_vim9_expr.vim, src/testdir/test_vim9_script.vim,
> src/vim9.h, src/vim9compile.c, src/vim9execute.c
>
Hi All,

After this patch, mingw spits out this compile warning and linker error
if FEAT_JOB_CHANNEL is not defined:
<snip>
gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603
-DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN
-DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer
-freg-struct-return vim9compile.c -o gobjnative/vim9compile.o
vim9compile.c: In function 'delete_instr':
vim9compile.c:5230:6: warning: implicit declaration of function
'job_unref'; did you mean 'blob_unref'? [-Wimplicit-function-declaration]
 5230 |      job_unref(isn->isn_arg.job);
      |      ^~~~~~~~~
      |      blob_unref
vim9compile.c:5234:6: warning: implicit declaration of function
'channel_unref' [-Wimplicit-function-declaration]
 5234 |      channel_unref(isn->isn_arg.channel);
      |      ^~~~~~~~~~~~~
gcc -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603
-DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN
-DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer
-freg-struct-return -Wl,-nxcompat,-dynamicbase -mwindows -municode -s -o
gvim.exe gobjnative/arabic.o gobjnative/arglist.o gobjnative/autocmd.o
gobjnative/beval.o gobjnative/blob.o gobjnative/blowfish.o
gobjnative/buffer.o gobjnative/bufwrite.o gobjnative/change.o
gobjnative/charset.o gobjnative/cindent.o gobjnative/cmdexpand.o
gobjnative/cmdhist.o gobjnative/crypt.o gobjnative/crypt_zip.o
gobjnative/debugger.o gobjnative/dict.o gobjnative/diff.o
gobjnative/digraph.o gobjnative/drawline.o gobjnative/drawscreen.o
gobjnative/edit.o gobjnative/eval.o gobjnative/evalbuffer.o
gobjnative/evalfunc.o gobjnative/evalvars.o gobjnative/evalwindow.o
gobjnative/ex_cmds.o gobjnative/ex_cmds2.o gobjnative/ex_docmd.o
gobjnative/ex_eval.o gobjnative/ex_getln.o gobjnative/fileio.o
gobjnative/filepath.o gobjnative/findfile.o gobjnative/fold.o
gobjnative/getchar.o gobjnative/hardcopy.o gobjnative/hashtab.o
gobjnative/highlight.o gobjnative/if_cscope.o gobjnative/indent.o
gobjnative/insexpand.o gobjnative/json.o gobjnative/list.o
gobjnative/main.o gobjnative/map.o gobjnative/mark.o
gobjnative/memfile.o gobjnative/memline.o gobjnative/menu.o
gobjnative/message.o gobjnative/misc1.o gobjnative/misc2.o
gobjnative/mouse.o gobjnative/move.o gobjnative/mbyte.o
gobjnative/normal.o gobjnative/ops.o gobjnative/option.o
gobjnative/optionstr.o gobjnative/os_mswin.o gobjnative/os_win32.o
gobjnative/pathdef.o gobjnative/popupmenu.o gobjnative/popupwin.o
gobjnative/profiler.o gobjnative/quickfix.o gobjnative/regexp.o
gobjnative/register.o gobjnative/scriptfile.o gobjnative/screen.o
gobjnative/search.o gobjnative/session.o gobjnative/sha256.o
gobjnative/sign.o gobjnative/spell.o gobjnative/spellfile.o
gobjnative/spellsuggest.o gobjnative/syntax.o gobjnative/tag.o
gobjnative/term.o gobjnative/testing.o gobjnative/textprop.o
gobjnative/time.o gobjnative/ui.o gobjnative/undo.o gobjnative/usercmd.o
gobjnative/userfunc.o gobjnative/version.o gobjnative/vim9compile.o
gobjnative/vim9execute.o gobjnative/vim9script.o gobjnative/viminfo.o
gobjnative/winclip.o gobjnative/window.o gobjnative/os_w32exe.o
gobjnative/vimrc.o gobjnative/xdiffi.o gobjnative/xemit.o
gobjnative/xprepare.o gobjnative/xutils.o gobjnative/xhistogram.o
gobjnative/xpatience.o gobjnative/gui.o gobjnative/gui_w32.o
gobjnative/gui_beval.o -lkernel32 -luser32 -lgdi32 -ladvapi32 -lcomdlg32
-lcomctl32 -lnetapi32 -lversion -lole32 -luuid
D:/Users/John/Documents/software/MinGW/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.1/../../../../x86_64-w64-mingw32/bin/ld.exe:
gobjnative/vim9compile.o:vim9compile.c:(.text+0x9689): undefined
reference to `job_unref'
D:/Users/John/Documents/software/MinGW/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.1/../../../../x86_64-w64-mingw32/bin/ld.exe:
gobjnative/vim9compile.o:vim9compile.c:(.text+0x96a9): undefined
reference to `channel_unref'
collect2.exe: error: ld returned 1 exit status
make: *** [Make_cyg_ming.mak:1043: gvim.exe] Error 1
</snip>

The attached patch tries to fix it.
Cheers
John
vim9compile.c.8.2.0336.patch

Bram Moolenaar

unread,
Mar 1, 2020, 8:49:43 AM3/1/20
to vim...@googlegroups.com, John Marriott

John Marriott wrote:

> On 01-Mar-2020 09:25, Bram Moolenaar wrote:
> > Patch 8.2.0336
> > Problem: Vim9: insufficient test coverage for compiling.
> > Solution: Add more tests.
> > Files: src/testdir/test_vim9_expr.vim, src/testdir/test_vim9_script.vim,
> > src/vim9.h, src/vim9compile.c, src/vim9execute.c
> >
> Hi All,
>
> After this patch, mingw spits out this compile warning and linker error
> if FEAT_JOB_CHANNEL is not defined:

[...]

> The attached patch tries to fix it.

Thanks. I had already sent out patch 8.2.0338 before reading the
message, it's doing the same thing.

--
hundred-and-one symptoms of being an internet addict:
142. You dream about creating the world's greatest web site.
Reply all
Reply to author
Forward
0 new messages