Patch 8.2.4582
Problem: Useless code handling a type declaration.
Solution: Remove the code and give an error.
Files: src/eval.c, src/errors.h, src/testdir/test_vim9_script.vim,
src/testdir/dumps/Test_misplaced_type.dump
*** ../vim-8.2.4581/src/eval.c 2022-03-16 13:09:11.329619036 +0000
--- src/eval.c 2022-03-16 19:22:03.991611834 +0000
***************
*** 937,944 ****
}
if (*p == ':')
{
- garray_T tmp_type_list;
- garray_T *type_list;
char_u *tp = skipwhite(p + 1);
if (tp == p + 1 && !quiet)
--- 937,942 ----
***************
*** 947,973 ****
return NULL;
}
! if (SCRIPT_ID_VALID(current_sctx.sc_sid))
! type_list = &SCRIPT_ITEM(current_sctx.sc_sid)->sn_type_list;
! else
{
! // TODO: should we give an error here?
! type_list = &tmp_type_list;
! ga_init2(type_list, sizeof(type_T), 10);
}
// parse the type after the name
! lp->ll_type = parse_type(&tp, type_list, !quiet);
if (lp->ll_type == NULL && !quiet)
return NULL;
lp->ll_name_end = tp;
-
- // drop the type when not in a script
- if (type_list == &tmp_type_list)
- {
- lp->ll_type = NULL;
- clear_type_list(type_list);
- }
}
}
}
--- 945,963 ----
return NULL;
}
! if (!SCRIPT_ID_VALID(current_sctx.sc_sid))
{
! semsg(_(e_using_type_not_in_script_context_str), p);
! return NULL;
}
// parse the type after the name
! lp->ll_type = parse_type(&tp,
! &SCRIPT_ITEM(current_sctx.sc_sid)->sn_type_list,
! !quiet);
if (lp->ll_type == NULL && !quiet)
return NULL;
lp->ll_name_end = tp;
}
}
}
*** ../vim-8.2.4581/src/errors.h 2022-03-15 15:57:00.426428445 +0000
--- src/errors.h 2022-03-16 19:23:11.135503157 +0000
***************
*** 3252,3255 ****
--- 3252,3257 ----
#ifdef FEAT_EVAL
EXTERN char e_compiling_closure_without_context_str[]
INIT(= N_("E1271: compiling closure without context: %s"));
+ EXTERN char e_using_type_not_in_script_context_str[]
+ INIT(= N_("E1272: Using type not in a script context: %s"));
#endif
*** ../vim-8.2.4581/src/testdir/test_vim9_script.vim 2022-03-15
16:16:44.275058631 +0000
--- src/testdir/test_vim9_script.vim 2022-03-16 19:40:08.152939691 +0000
***************
*** 3942,3951 ****
enddef
def Profile()
- profile start Xprofile.log
- profile func ProfiledWithLambda
- # mark ProfiledNested for profiling to avoid E1271
- profile func ProfiledNested
ProfiledWithLambda()
ProfiledNested()
--- 3942,3947 ----
***************
*** 3957,3964 ****
profdel func *
profile pause
enddef
! Profile()
! writefile(['done'], 'Xdidprofile')
END
writefile(lines, 'Xprofile.vim')
call system(g:GetVimCommand()
--- 3953,3972 ----
profdel func *
profile pause
enddef
!
! var result = 'done'
! try
! # mark functions for profiling now to avoid E1271
! profile start Xprofile.log
! profile func ProfiledWithLambda
! profile func ProfiledNested
!
! Profile()
! catch
! result = 'failed: ' .. v:exception
! finally
! writefile([result], 'Xdidprofile')
! endtry
END
writefile(lines, 'Xprofile.vim')
call system(g:GetVimCommand()
***************
*** 3974,3979 ****
--- 3982,3997 ----
delete('Xprofile.vim')
enddef
+ def Test_misplaced_type()
+ writefile(['let g:somevar = "asdf"'], 'XTest_misplaced_type')
+ var buf = g:RunVimInTerminal('-S XTest_misplaced_type', {'rows': 6})
+ term_sendkeys(buf, ":vim9cmd echo islocked('g:somevar: string')\<CR>")
+ g:VerifyScreenDump(buf, 'Test_misplaced_type', {})
+
+ g:StopVimInTerminal(buf)
+ delete('XTest_misplaced_type')
+ enddef
+
" Keep this last, it messes up highlighting.
def Test_substitute_cmd()
new
*** ../vim-8.2.4581/src/testdir/dumps/Test_misplaced_type.dump 2022-03-16
19:58:42.586019851 +0000
--- src/testdir/dumps/Test_misplaced_type.dump 2022-03-16 19:38:20.049892350
+0000
***************
*** 0 ****
--- 1,6 ----
+ |~+0#4040ff13#ffffff0| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |E+0#ffffff16#e000002|1|2|7|2|:| |U|s|i|n|g| |t|y|p|e| |n|o|t| |i|n| |a|
|s|c|r|i|p|t| |c|o|n|t|e|x|t|:| |:| |s|t|r|i|n|g| +0#0000000#ffffff0@23
+ |P+0#00e0003&|r|e|s@1| |E|N|T|E|R| |o|r| |t|y|p|e| |c|o|m@1|a|n|d| |t|o|
|c|o|n|t|i|n|u|e> +0#0000000&@35
*** ../vim-8.2.4581/src/version.c 2022-03-16 17:56:30.379316935 +0000
--- src/version.c 2022-03-16 19:23:21.639485934 +0000
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 4582,
/**/
--
Bravely bold Sir Robin, rode forth from Camelot,
He was not afraid to die, Oh Brave Sir Robin,
He was not at all afraid to be killed in nasty ways
Brave, brave, brave, brave Sir Robin.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220316200211.ED14A1C0497%40moolenaar.net.