patch 8.2.0336: Vim9: insufficient test coverage for compiling
Problem: Vim9: insufficient test coverage for compiling.
Solution: Add more tests.
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 35f20c4..a4525ca 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -642,6 +642,38 @@
}
/*
+ * 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,6 +690,22 @@
}
/*
+ * 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,10 +3597,11 @@
generate_PUSHBLOB(cctx, NULL);
break;
case VAR_FUNC:
- // generate_PUSHS(cctx, NULL); TODO
+ generate_PUSHFUNC(cctx, NULL);
break;
case VAR_PARTIAL:
- // generate_PUSHS(cctx, NULL); TODO
+ // generate_PUSHPARTIAL(cctx, NULL);
+ emsg("Partial type not supported yet");
break;
case VAR_LIST:
generate_NEWLIST(cctx, 0);
@@ -3561,10 +3610,10 @@
generate_NEWDICT(cctx, 0);
break;
case VAR_JOB:
- // generate_PUSHS(cctx, NULL); TODO
+ generate_PUSHJOB(cctx, NULL);
break;
case VAR_CHANNEL:
- // generate_PUSHS(cctx, NULL); TODO
+ generate_PUSHCHANNEL(cctx, NULL);
break;
case VAR_NUMBER:
case VAR_UNKNOWN:
@@ -4748,6 +4797,7 @@
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,7 +4878,8 @@
++line;
else if (line != NULL && *line != NUL)
{
- semsg(_("E488: Trailing characters: %s"), line);
+ if (emsg_before == called_emsg)
+ semsg(_("E488: Trailing characters: %s"), line);
goto erret;
}
else
@@ -4844,6 +4895,7 @@
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,6 +5205,7 @@
case ISN_PUSHS:
case ISN_STOREENV:
case ISN_STOREG:
+ case ISN_PUSHFUNC:
vim_free(isn->isn_arg.string);
break;
@@ -5169,6 +5222,18 @@
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;