• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revisão11609f025219de61f30e5ca319fb9819aa033690 (tree)
Hora2022-05-18 00:15:03
AutorBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Mensagem de Log

patch 8.2.4973: Vim9: type error for list unpack mentions argument

Commit: https://github.com/vim/vim/commit/bd3a9d2c946bae0427d7c9b9249716064935fb4e
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue May 17 16:12:39 2022 +0100

patch 8.2.4973: Vim9: type error for list unpack mentions argument
Problem: Vim9: type error for list unpack mentions argument.
Solution: Mention variable. (close https://github.com/vim/vim/issues/10435)

Mudança Sumário

Diff

diff -r 7630685d3e43 -r 11609f025219 src/proto/vim9instr.pro
--- a/src/proto/vim9instr.pro Tue May 17 16:15:03 2022 +0200
+++ b/src/proto/vim9instr.pro Tue May 17 17:15:03 2022 +0200
@@ -9,9 +9,10 @@
99 int generate_two_op(cctx_T *cctx, char_u *op);
1010 int check_compare_types(exprtype_T type, typval_T *tv1, typval_T *tv2);
1111 int generate_COMPARE(cctx_T *cctx, exprtype_T exprtype, int ic);
12+int generate_CONCAT(cctx_T *cctx, int count);
1213 int generate_2BOOL(cctx_T *cctx, int invert, int offset);
1314 int generate_COND2BOOL(cctx_T *cctx);
14-int generate_TYPECHECK(cctx_T *cctx, type_T *expected, int offset, int argidx);
15+int generate_TYPECHECK(cctx_T *cctx, type_T *expected, int offset, int is_var, int argidx);
1516 int generate_SETTYPE(cctx_T *cctx, type_T *expected);
1617 int generate_tv_PUSH(cctx_T *cctx, typval_T *tv);
1718 int generate_PUSHNR(cctx_T *cctx, varnumber_T number);
@@ -62,7 +63,6 @@
6263 int generate_EXECCONCAT(cctx_T *cctx, int count);
6364 int generate_RANGE(cctx_T *cctx, char_u *range);
6465 int generate_UNPACK(cctx_T *cctx, int var_count, int semicolon);
65-int generate_CONCAT(cctx_T *cctx, int count);
6666 int generate_cmdmods(cctx_T *cctx, cmdmod_T *cmod);
6767 int generate_undo_cmdmods(cctx_T *cctx);
6868 int generate_store_var(cctx_T *cctx, assign_dest_T dest, int opt_flags, int vimvaridx, int scriptvar_idx, int scriptvar_sid, type_T *type, char_u *name);
diff -r 7630685d3e43 -r 11609f025219 src/testdir/test_vim9_disassemble.vim
--- a/src/testdir/test_vim9_disassemble.vim Tue May 17 16:15:03 2022 +0200
+++ b/src/testdir/test_vim9_disassemble.vim Tue May 17 17:15:03 2022 +0200
@@ -581,10 +581,10 @@
581581 '\d CHECKTYPE list<any> stack\[-1\]\_s*' ..
582582 '\d CHECKLEN >= 2\_s*' ..
583583 '\d\+ ITEM 0\_s*' ..
584- '\d\+ CHECKTYPE string stack\[-1\] arg 1\_s*' ..
584+ '\d\+ CHECKTYPE string stack\[-1\] var 1\_s*' ..
585585 '\d\+ STORE $0\_s*' ..
586586 '\d\+ ITEM 1\_s*' ..
587- '\d\+ CHECKTYPE string stack\[-1\] arg 2\_s*' ..
587+ '\d\+ CHECKTYPE string stack\[-1\] var 2\_s*' ..
588588 '\d\+ STORE $1\_s*' ..
589589 '\d\+ SLICE 2\_s*' ..
590590 '\d\+ STORE $2\_s*' ..
diff -r 7630685d3e43 -r 11609f025219 src/testdir/test_vim9_script.vim
--- a/src/testdir/test_vim9_script.vim Tue May 17 16:15:03 2022 +0200
+++ b/src/testdir/test_vim9_script.vim Tue May 17 17:15:03 2022 +0200
@@ -2302,7 +2302,7 @@
23022302 echo k v
23032303 endfor
23042304 END
2305- v9.CheckDefExecAndScriptFailure(lines, ['E1013: Argument 1: type mismatch, expected job but got string', 'E1012: Type mismatch; expected job but got string'], 2)
2305+ v9.CheckDefExecAndScriptFailure(lines, ['E1163: Variable 1: type mismatch, expected job but got string', 'E1012: Type mismatch; expected job but got string'], 2)
23062306
23072307 lines =<< trim END
23082308 var i = 0
diff -r 7630685d3e43 -r 11609f025219 src/version.c
--- a/src/version.c Tue May 17 16:15:03 2022 +0200
+++ b/src/version.c Tue May 17 17:15:03 2022 +0200
@@ -747,6 +747,8 @@
747747 static int included_patches[] =
748748 { /* Add new patch number below this line */
749749 /**/
750+ 4973,
751+/**/
750752 4972,
751753 /**/
752754 4971,
diff -r 7630685d3e43 -r 11609f025219 src/vim9.h
--- a/src/vim9.h Tue May 17 16:15:03 2022 +0200
+++ b/src/vim9.h Tue May 17 17:15:03 2022 +0200
@@ -296,6 +296,7 @@
296296 type_T *ct_type;
297297 int8_T ct_off; // offset in stack, -1 is bottom
298298 int8_T ct_arg_idx; // argument index or zero
299+ int8_T ct_is_var; // when TRUE checking variable instead of arg
299300 } checktype_T;
300301
301302 // arguments to ISN_STORENR
diff -r 7630685d3e43 -r 11609f025219 src/vim9compile.c
--- a/src/vim9compile.c Tue May 17 16:15:03 2022 +0200
+++ b/src/vim9compile.c Tue May 17 17:15:03 2022 +0200
@@ -412,7 +412,8 @@
412412 // If the actual type can be the expected type add a runtime check.
413413 if (!actual_is_const && ret == MAYBE && use_typecheck(actual, expected))
414414 {
415- generate_TYPECHECK(cctx, expected, offset, where.wt_index);
415+ generate_TYPECHECK(cctx, expected, offset,
416+ where.wt_variable, where.wt_index);
416417 return OK;
417418 }
418419
diff -r 7630685d3e43 -r 11609f025219 src/vim9execute.c
--- a/src/vim9execute.c Tue May 17 16:15:03 2022 +0200
+++ b/src/vim9execute.c Tue May 17 17:15:03 2022 +0200
@@ -4652,14 +4652,17 @@
46524652 case ISN_CHECKTYPE:
46534653 {
46544654 checktype_T *ct = &iptr->isn_arg.type;
4655+ int save_wt_variable = ectx->ec_where.wt_variable;
46554656
46564657 tv = STACK_TV_BOT((int)ct->ct_off);
46574658 SOURCING_LNUM = iptr->isn_lnum;
46584659 if (!ectx->ec_where.wt_variable)
46594660 ectx->ec_where.wt_index = ct->ct_arg_idx;
4661+ ectx->ec_where.wt_variable = ct->ct_is_var;
46604662 if (check_typval_type(ct->ct_type, tv, ectx->ec_where)
46614663 == FAIL)
46624664 goto on_error;
4665+ ectx->ec_where.wt_variable = save_wt_variable;
46634666 if (!ectx->ec_where.wt_variable)
46644667 ectx->ec_where.wt_index = 0;
46654668
@@ -6114,18 +6117,19 @@
61146117
61156118 case ISN_CHECKTYPE:
61166119 {
6117- checktype_T *ct = &iptr->isn_arg.type;
6118- char *tofree;
6120+ checktype_T *ct = &iptr->isn_arg.type;
6121+ char *tofree;
61196122
61206123 if (ct->ct_arg_idx == 0)
61216124 smsg("%s%4d CHECKTYPE %s stack[%d]", pfx, current,
61226125 type_name(ct->ct_type, &tofree),
61236126 (int)ct->ct_off);
61246127 else
6125- smsg("%s%4d CHECKTYPE %s stack[%d] arg %d",
6128+ smsg("%s%4d CHECKTYPE %s stack[%d] %s %d",
61266129 pfx, current,
61276130 type_name(ct->ct_type, &tofree),
61286131 (int)ct->ct_off,
6132+ ct->ct_is_var ? "var": "arg",
61296133 (int)ct->ct_arg_idx);
61306134 vim_free(tofree);
61316135 break;
diff -r 7630685d3e43 -r 11609f025219 src/vim9instr.c
--- a/src/vim9instr.c Tue May 17 16:15:03 2022 +0200
+++ b/src/vim9instr.c Tue May 17 17:15:03 2022 +0200
@@ -542,6 +542,7 @@
542542 cctx_T *cctx,
543543 type_T *expected,
544544 int offset,
545+ int is_var,
545546 int argidx)
546547 {
547548 isn_T *isn;
@@ -551,6 +552,7 @@
551552 return FAIL;
552553 isn->isn_arg.type.ct_type = alloc_type(expected);
553554 isn->isn_arg.type.ct_off = (int8_T)offset;
555+ isn->isn_arg.type.ct_is_var = is_var;
554556 isn->isn_arg.type.ct_arg_idx = (int8_T)argidx;
555557
556558 // type becomes expected
@@ -1437,7 +1439,7 @@
14371439 if (maptype != NULL && maptype[0].type_decl->tt_member != NULL
14381440 && maptype[0].type_decl->tt_member != &t_any)
14391441 // Check that map() didn't change the item types.
1440- generate_TYPECHECK(cctx, maptype[0].type_decl, -1, 1);
1442+ generate_TYPECHECK(cctx, maptype[0].type_decl, -1, FALSE, 1);
14411443
14421444 return OK;
14431445 }
Show on old repository browser