To: vim_dev@googlegroups.com Subject: Patch 8.2.2266 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2266 Problem: Vim9: it can be hard to see where white space is missing. Solution: Mention the text where the error was seen. (closes #7580) Files: src/errors.h, src/eval.c, src/evalvars.c, src/userfunc.c, src/vim9compile.c, src/testdir/test_vim9_expr.vim *** ../vim-8.2.2265/src/errors.h 2021-01-01 18:43:46.260466448 +0100 --- src/errors.h 2021-01-01 19:01:10.477765809 +0100 *************** *** 41,48 **** INIT(= N_("E1002: Syntax error at %s")); EXTERN char e_missing_return_value[] INIT(= N_("E1003: Missing return value")); ! EXTERN char e_white_space_required_before_and_after_str[] ! INIT(= N_("E1004: White space required before and after '%s'")); EXTERN char e_too_many_argument_types[] INIT(= N_("E1005: Too many argument types")); EXTERN char e_str_is_used_as_argument[] --- 41,48 ---- INIT(= N_("E1002: Syntax error at %s")); EXTERN char e_missing_return_value[] INIT(= N_("E1003: Missing return value")); ! EXTERN char e_white_space_required_before_and_after_str_at_str[] ! INIT(= N_("E1004: White space required before and after '%s' at \"%s\"")); EXTERN char e_too_many_argument_types[] INIT(= N_("E1005: Too many argument types")); EXTERN char e_str_is_used_as_argument[] *** ../vim-8.2.2265/src/eval.c 2020-12-31 21:28:43.419217945 +0100 --- src/eval.c 2021-01-01 18:59:12.258114048 +0100 *************** *** 3778,3784 **** return FAIL; else if (vim9 && **arg == ':') { ! semsg(_(e_white_space_required_before_and_after_str), ":"); clear_tv(&var1); return FAIL; } --- 3778,3785 ---- return FAIL; else if (vim9 && **arg == ':') { ! semsg(_(e_white_space_required_before_and_after_str_at_str), ! ":", *arg); clear_tv(&var1); return FAIL; } *************** *** 3799,3805 **** ++*arg; if (vim9 && !IS_WHITE_OR_NUL(**arg) && **arg != ']') { ! semsg(_(e_white_space_required_before_and_after_str), ":"); if (!empty1) clear_tv(&var1); return FAIL; --- 3800,3807 ---- ++*arg; if (vim9 && !IS_WHITE_OR_NUL(**arg) && **arg != ']') { ! semsg(_(e_white_space_required_before_and_after_str_at_str), ! ":", *arg - 1); if (!empty1) clear_tv(&var1); return FAIL; *** ../vim-8.2.2265/src/evalvars.c 2021-01-01 15:11:00.008727261 +0100 --- src/evalvars.c 2021-01-01 19:02:41.313495141 +0100 *************** *** 863,869 **** || !IS_WHITE_OR_NUL(*expr))) { vim_strncpy(op, expr - len, len); ! semsg(_(e_white_space_required_before_and_after_str), op); i = FAIL; } --- 863,870 ---- || !IS_WHITE_OR_NUL(*expr))) { vim_strncpy(op, expr - len, len); ! semsg(_(e_white_space_required_before_and_after_str_at_str), ! op, argend); i = FAIL; } *** ../vim-8.2.2265/src/userfunc.c 2021-01-01 18:54:31.034916407 +0100 --- src/userfunc.c 2021-01-01 19:03:54.105276577 +0100 *************** *** 501,508 **** || !IS_WHITE_OR_NUL(s[1]))) { *white_error = TRUE; ! semsg(_(e_white_space_required_before_and_after_str), ! equal_arrow ? "=>" : "->"); return NULL; } return skipwhite(s + 1); --- 501,508 ---- || !IS_WHITE_OR_NUL(s[1]))) { *white_error = TRUE; ! semsg(_(e_white_space_required_before_and_after_str_at_str), ! equal_arrow ? "=>" : "->", bef); return NULL; } return skipwhite(s + 1); *** ../vim-8.2.2265/src/vim9compile.c 2021-01-01 16:10:42.474679574 +0100 --- src/vim9compile.c 2021-01-01 19:07:02.496705529 +0100 *************** *** 3656,3662 **** return FAIL; if (**arg == ':') { ! semsg(_(e_white_space_required_before_and_after_str), ":"); return FAIL; } if (may_get_next_line_error(p, arg, cctx) == FAIL) --- 3656,3663 ---- return FAIL; if (**arg == ':') { ! semsg(_(e_white_space_required_before_and_after_str_at_str), ! ":", *arg); return FAIL; } if (may_get_next_line_error(p, arg, cctx) == FAIL) *************** *** 3669,3675 **** ++*arg; if (!IS_WHITE_OR_NUL(**arg) && **arg != ']') { ! semsg(_(e_white_space_required_before_and_after_str), ":"); return FAIL; } *arg = skipwhite(*arg); --- 3670,3677 ---- ++*arg; if (!IS_WHITE_OR_NUL(**arg) && **arg != ']') { ! semsg(_(e_white_space_required_before_and_after_str_at_str), ! ":", *arg); return FAIL; } *arg = skipwhite(*arg); *************** *** 4067,4073 **** char_u buf[10]; vim_strncpy(buf, op, len); ! semsg(_(e_white_space_required_before_and_after_str), buf); } /* --- 4069,4075 ---- char_u buf[10]; vim_strncpy(buf, op, len); ! semsg(_(e_white_space_required_before_and_after_str_at_str), buf, op); } /* *************** *** 4434,4440 **** if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[2])) { ! semsg(_(e_white_space_required_before_and_after_str), op); return FAIL; } --- 4436,4443 ---- if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[2])) { ! semsg(_(e_white_space_required_before_and_after_str_at_str), ! op, *arg); return FAIL; } *************** *** 4608,4615 **** if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[1 + op_falsy])) { ! semsg(_(e_white_space_required_before_and_after_str), ! op_falsy ? "??" : "?"); return FAIL; } --- 4611,4618 ---- if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[1 + op_falsy])) { ! semsg(_(e_white_space_required_before_and_after_str_at_str), ! op_falsy ? "??" : "?", *arg); return FAIL; } *************** *** 4695,4701 **** if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[1])) { ! semsg(_(e_white_space_required_before_and_after_str), ":"); return FAIL; } --- 4698,4705 ---- if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[1])) { ! semsg(_(e_white_space_required_before_and_after_str_at_str), ! ":", p); return FAIL; } *** ../vim-8.2.2265/src/testdir/test_vim9_expr.vim 2021-01-01 15:11:00.008727261 +0100 --- src/testdir/test_vim9_expr.vim 2021-01-01 19:16:57.102272496 +0100 *************** *** 108,114 **** vim9script var name = v:true?1:2 END ! CheckScriptFailure(lines, 'E1004:', 2) lines =<< trim END vim9script var name = v:true? 1 : 2 --- 108,114 ---- vim9script var name = v:true?1:2 END ! CheckScriptFailure(lines, 'E1004: White space required before and after ''?'' at "?1:2"', 2) lines =<< trim END vim9script var name = v:true? 1 : 2 *************** *** 123,129 **** vim9script var name = v:true ? 1: 2 END ! CheckScriptFailure(lines, 'E1004:', 2) lines =<< trim END vim9script var name = v:true ? 1 :2 --- 123,129 ---- vim9script var name = v:true ? 1: 2 END ! CheckScriptFailure(lines, 'E1004: White space required before and after '':'' at ": 2"', 2) lines =<< trim END vim9script var name = v:true ? 1 :2 *************** *** 333,339 **** vim9script var name = v:true||v:true END ! CheckScriptFailure(lines, 'E1004:', 2) lines =<< trim END vim9script var name = v:true ||v:true --- 333,339 ---- vim9script var name = v:true||v:true END ! CheckScriptFailure(lines, 'E1004: White space required before and after ''||'' at "||v:true"', 2) lines =<< trim END vim9script var name = v:true ||v:true *************** *** 454,460 **** vim9script var name = v:true &&v:true END ! CheckScriptFailure(lines, 'E1004:', 2) lines =<< trim END vim9script var name = v:true&& v:true --- 454,460 ---- vim9script var name = v:true &&v:true END ! CheckScriptFailure(lines, 'E1004: White space required before and after ''&&'' at "&&v:true"', 2) lines =<< trim END vim9script var name = v:true&& v:true *************** *** 920,926 **** vim9script echo 2>3 END ! CheckScriptFailure(lines, 'E1004:', 2) lines =<< trim END vim9script echo 2 >3 --- 920,926 ---- vim9script echo 2>3 END ! CheckScriptFailure(lines, 'E1004: White space required before and after ''>'' at ">3"', 2) lines =<< trim END vim9script echo 2 >3 *************** *** 940,946 **** vim9script echo 2 !=3 END ! CheckScriptFailure(lines, 'E1004:', 2) lines =<< trim END vim9script echo 2!= 3 --- 940,946 ---- vim9script echo 2 !=3 END ! CheckScriptFailure(lines, 'E1004: White space required before and after ''!'' at "!=3"', 2) lines =<< trim END vim9script echo 2!= 3 *************** *** 1192,1198 **** vim9script echo 'a'..'b' END ! CheckScriptFailure(lines, 'E1004:', 2) lines =<< trim END vim9script echo 'a' ..'b' --- 1192,1198 ---- vim9script echo 'a'..'b' END ! CheckScriptFailure(lines, 'E1004: White space required before and after ''..'' at "..''b''"', 2) lines =<< trim END vim9script echo 'a' ..'b' *************** *** 1729,1735 **** var a = 1 var b = 2 END ! CheckDefAndScriptFailure(lines + ['echo numbers[1:b]'], 'E1004:', 4) CheckDefAndScriptFailure(lines + ['echo numbers[1: b]'], 'E1004:', 4) CheckDefAndScriptFailure(lines + ['echo numbers[a :b]'], 'E1004:', 4) enddef --- 1729,1736 ---- var a = 1 var b = 2 END ! CheckDefAndScriptFailure(lines + ['echo numbers[1:b]'], ! 'E1004: White space required before and after '':'' at ":b]"', 4) CheckDefAndScriptFailure(lines + ['echo numbers[1: b]'], 'E1004:', 4) CheckDefAndScriptFailure(lines + ['echo numbers[a :b]'], 'E1004:', 4) enddef *************** *** 1876,1882 **** CheckDefAndScriptSuccess(lines) CheckDefFailure(["var Ref = (a)=>a + 1"], 'E1004:') ! CheckDefFailure(["var Ref = (a)=> a + 1"], 'E1004:') CheckDefFailure(["var Ref = (a) =>a + 1"], 'E1004:') CheckDefFailure(["filter([1, 2], (k,v) => 1)"], 'E1069:', 1) --- 1877,1883 ---- CheckDefAndScriptSuccess(lines) CheckDefFailure(["var Ref = (a)=>a + 1"], 'E1004:') ! CheckDefFailure(["var Ref = (a)=> a + 1"], 'E1004: White space required before and after ''=>'' at "=> a + 1"') CheckDefFailure(["var Ref = (a) =>a + 1"], 'E1004:') CheckDefFailure(["filter([1, 2], (k,v) => 1)"], 'E1069:', 1) *************** *** 1976,1982 **** CheckDefAndScriptFailure(["var Ref = (a)=>a + 1"], 'E1004:') CheckDefAndScriptFailure(["var Ref = (a)=> a + 1"], 'E1004:') ! CheckDefAndScriptFailure(["var Ref = (a) =>a + 1"], 'E1004:') CheckDefFailure(["var Ref: func(number): number = (a: number): string => 'x'"], 'E1012:') CheckDefFailure(["var Ref: func(number): string = (a: number): string => 99"], 'E1012:') --- 1977,1984 ---- CheckDefAndScriptFailure(["var Ref = (a)=>a + 1"], 'E1004:') CheckDefAndScriptFailure(["var Ref = (a)=> a + 1"], 'E1004:') ! CheckDefAndScriptFailure(["var Ref = (a) =>a + 1"], ! 'E1004: White space required before and after ''=>'' at " =>a + 1"') CheckDefFailure(["var Ref: func(number): number = (a: number): string => 'x'"], 'E1012:') CheckDefFailure(["var Ref: func(number): string = (a: number): string => 99"], 'E1012:') *** ../vim-8.2.2265/src/version.c 2021-01-01 18:54:31.034916407 +0100 --- src/version.c 2021-01-01 19:17:25.454119225 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2266, /**/ -- hundred-and-one symptoms of being an internet addict: 80. At parties, you introduce your spouse as your "service provider." /// Bram Moolenaar -- Bram@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 ///