To: vim_dev@googlegroups.com Subject: Patch 8.2.3317 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3317 Problem: Vim9: No error for missing white space before return type. Solution: Check for white space. (closes #8733) Files: src/userfunc.c, src/testdir/test_vim9_func.vim *** ../vim-8.2.3316/src/userfunc.c 2021-08-05 20:39:59.354053658 +0200 --- src/userfunc.c 2021-08-08 19:06:29.204840127 +0200 *************** *** 4066,4073 **** if (eap->cmdidx == CMD_def) { // find the return type: :def Func(): type ! if (*p == ':') { ret_type = skipwhite(p + 1); p = skip_type(ret_type, FALSE); if (p > ret_type) --- 4066,4080 ---- if (eap->cmdidx == CMD_def) { // find the return type: :def Func(): type ! if (*skipwhite(p) == ':') { + if (*p != ':') + { + semsg(_(e_no_white_space_allowed_before_colon_str), p); + p = skipwhite(p); + } + else if (!IS_WHITE_OR_NUL(p[1])) + semsg(_(e_white_space_required_after_str_str), ":", p); ret_type = skipwhite(p + 1); p = skip_type(ret_type, FALSE); if (p > ret_type) *** ../vim-8.2.3316/src/testdir/test_vim9_func.vim 2021-08-07 15:35:32.790064386 +0200 --- src/testdir/test_vim9_func.vim 2021-08-08 19:04:37.613143116 +0200 *************** *** 1429,1434 **** --- 1429,1455 ---- 'defcompile'], 'E1003:') delfunc! g:Func + CheckScriptFailure([ + 'def Func():number', + 'return 123', + 'enddef', + 'defcompile'], 'E1069:') + delfunc! g:Func + + CheckScriptFailure([ + 'def Func() :number', + 'return 123', + 'enddef', + 'defcompile'], 'E1059:') + delfunc! g:Func + + CheckScriptFailure([ + 'def Func() : number', + 'return 123', + 'enddef', + 'defcompile'], 'E1059:') + delfunc! g:Func + CheckScriptFailure(['def Func(): list', 'return []', 'enddef'], 'E1008:') delfunc! g:Func CheckScriptFailure(['def Func(): dict', 'return {}', 'enddef'], 'E1008:') *** ../vim-8.2.3316/src/version.c 2021-08-08 15:51:07.119909726 +0200 --- src/version.c 2021-08-08 18:58:40.450124765 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3317, /**/ -- ARTHUR: Shut up! Will you shut up! DENNIS: Ah, now we see the violence inherent in the system. ARTHUR: Shut up! DENNIS: Oh! Come and see the violence inherent in the system! HELP! HELP! I'm being repressed! The Quest for the Holy Grail (Monty Python) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///