vim-patch:9.0.1950: Vim9: error codes spread out (#25405)

Problem:  Vim9: error codes spread out
Solution: group them together and reserve 100
          more for future use

Reserve 100 error codes for future enhancements to the Vim9 class
support

closes: vim/vim#13207

413f83990f

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
zeertzjq 2023-09-29 06:52:02 +08:00 committed by GitHub
parent 1117d29b20
commit 7ec20a4082
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 104 additions and 104 deletions

View File

@ -5255,55 +5255,55 @@ printf({fmt}, {expr1} ...) *printf()*
echo printf("%1$*2$.*3$f", 1.4142135, 6, 2)
< 1.41
*E1400*
*E1500*
You cannot mix positional and non-positional arguments: >vim
echo printf("%s%1$s", "One", "Two")
< E1400: Cannot mix positional and non-positional
< E1500: Cannot mix positional and non-positional
arguments: %s%1$s
*E1401*
*E1501*
You cannot skip a positional argument in a format string: >vim
echo printf("%3$s%1$s", "One", "Two", "Three")
< E1401: format argument 2 unused in $-style
< E1501: format argument 2 unused in $-style
format: %3$s%1$s
*E1402*
*E1502*
You can re-use a [field-width] (or [precision]) argument: >vim
echo printf("%1$d at width %2$d is: %01$*2$d", 1, 2)
< 1 at width 2 is: 01
However, you can't use it as a different type: >vim
echo printf("%1$d at width %2$ld is: %01$*2$d", 1, 2)
< E1402: Positional argument 2 used as field
< E1502: Positional argument 2 used as field
width reused as different type: long int/int
*E1403*
*E1503*
When a positional argument is used, but not the correct number
or arguments is given, an error is raised: >vim
echo printf("%1$d at width %2$d is: %01$*2$.*3$d", 1, 2)
< E1403: Positional argument 3 out of bounds:
< E1503: Positional argument 3 out of bounds:
%1$d at width %2$d is: %01$*2$.*3$d
Only the first error is reported: >vim
echo printf("%01$*2$.*3$d %4$d", 1, 2)
< E1403: Positional argument 3 out of bounds:
< E1503: Positional argument 3 out of bounds:
%01$*2$.*3$d %4$d
*E1404*
*E1504*
A positional argument can be used more than once: >vim
echo printf("%1$s %2$s %1$s", "One", "Two")
< One Two One
However, you can't use a different type the second time: >vim
echo printf("%1$s %2$s %1$d", "One", "Two")
< E1404: Positional argument 1 type used
< E1504: Positional argument 1 type used
inconsistently: int/string
*E1405*
*E1505*
Various other errors that lead to a format string being
wrongly formatted lead to: >vim
echo printf("%1$d at width %2$d is: %01$*2$.3$d", 1, 2)
< E1405: Invalid format specifier:
< E1505: Invalid format specifier:
%1$d at width %2$d is: %01$*2$.3$d
prompt_getprompt({buf}) *prompt_getprompt()*

View File

@ -6238,55 +6238,55 @@ function vim.fn.prevnonblank(lnum) end
--- echo printf("%1$*2$.*3$f", 1.4142135, 6, 2)
--- < 1.41
---
--- *E1400*
--- *E1500*
--- You cannot mix positional and non-positional arguments: >vim
--- echo printf("%s%1$s", "One", "Two")
--- < E1400: Cannot mix positional and non-positional
--- < E1500: Cannot mix positional and non-positional
--- arguments: %s%1$s
---
--- *E1401*
--- *E1501*
--- You cannot skip a positional argument in a format string: >vim
--- echo printf("%3$s%1$s", "One", "Two", "Three")
--- < E1401: format argument 2 unused in $-style
--- < E1501: format argument 2 unused in $-style
--- format: %3$s%1$s
---
--- *E1402*
--- *E1502*
--- You can re-use a [field-width] (or [precision]) argument: >vim
--- echo printf("%1$d at width %2$d is: %01$*2$d", 1, 2)
--- < 1 at width 2 is: 01
---
--- However, you can't use it as a different type: >vim
--- echo printf("%1$d at width %2$ld is: %01$*2$d", 1, 2)
--- < E1402: Positional argument 2 used as field
--- < E1502: Positional argument 2 used as field
--- width reused as different type: long int/int
---
--- *E1403*
--- *E1503*
--- When a positional argument is used, but not the correct number
--- or arguments is given, an error is raised: >vim
--- echo printf("%1$d at width %2$d is: %01$*2$.*3$d", 1, 2)
--- < E1403: Positional argument 3 out of bounds:
--- < E1503: Positional argument 3 out of bounds:
--- %1$d at width %2$d is: %01$*2$.*3$d
---
--- Only the first error is reported: >vim
--- echo printf("%01$*2$.*3$d %4$d", 1, 2)
--- < E1403: Positional argument 3 out of bounds:
--- < E1503: Positional argument 3 out of bounds:
--- %01$*2$.*3$d %4$d
---
--- *E1404*
--- *E1504*
--- A positional argument can be used more than once: >vim
--- echo printf("%1$s %2$s %1$s", "One", "Two")
--- < One Two One
---
--- However, you can't use a different type the second time: >vim
--- echo printf("%1$s %2$s %1$d", "One", "Two")
--- < E1404: Positional argument 1 type used
--- < E1504: Positional argument 1 type used
--- inconsistently: int/string
---
--- *E1405*
--- *E1505*
--- Various other errors that lead to a format string being
--- wrongly formatted lead to: >vim
--- echo printf("%1$d at width %2$d is: %01$*2$.3$d", 1, 2)
--- < E1405: Invalid format specifier:
--- < E1505: Invalid format specifier:
--- %1$d at width %2$d is: %01$*2$.3$d
---
--- @param fmt any

View File

@ -7520,55 +7520,55 @@ M.funcs = {
echo printf("%1$*2$.*3$f", 1.4142135, 6, 2)
< 1.41
*E1400*
*E1500*
You cannot mix positional and non-positional arguments: >vim
echo printf("%s%1$s", "One", "Two")
< E1400: Cannot mix positional and non-positional
arguments: %s%1$s
echo printf("%s%1$s", "One", "Two")
< E1500: Cannot mix positional and non-positional
arguments: %s%1$s
*E1401*
*E1501*
You cannot skip a positional argument in a format string: >vim
echo printf("%3$s%1$s", "One", "Two", "Three")
< E1401: format argument 2 unused in $-style
< E1501: format argument 2 unused in $-style
format: %3$s%1$s
*E1402*
*E1502*
You can re-use a [field-width] (or [precision]) argument: >vim
echo printf("%1$d at width %2$d is: %01$*2$d", 1, 2)
< 1 at width 2 is: 01
However, you can't use it as a different type: >vim
echo printf("%1$d at width %2$ld is: %01$*2$d", 1, 2)
< E1402: Positional argument 2 used as field
< E1502: Positional argument 2 used as field
width reused as different type: long int/int
*E1403*
*E1503*
When a positional argument is used, but not the correct number
or arguments is given, an error is raised: >vim
echo printf("%1$d at width %2$d is: %01$*2$.*3$d", 1, 2)
< E1403: Positional argument 3 out of bounds:
< E1503: Positional argument 3 out of bounds:
%1$d at width %2$d is: %01$*2$.*3$d
Only the first error is reported: >vim
echo printf("%01$*2$.*3$d %4$d", 1, 2)
< E1403: Positional argument 3 out of bounds:
< E1503: Positional argument 3 out of bounds:
%01$*2$.*3$d %4$d
*E1404*
*E1504*
A positional argument can be used more than once: >vim
echo printf("%1$s %2$s %1$s", "One", "Two")
< One Two One
However, you can't use a different type the second time: >vim
echo printf("%1$s %2$s %1$d", "One", "Two")
< E1404: Positional argument 1 type used
< E1504: Positional argument 1 type used
inconsistently: int/string
*E1405*
*E1505*
Various other errors that lead to a format string being
wrongly formatted lead to: >vim
echo printf("%1$d at width %2$d is: %01$*2$.3$d", 1, 2)
< E1405: Invalid format specifier:
< E1505: Invalid format specifier:
%1$d at width %2$d is: %01$*2$.3$d
]=],
name = 'printf',

View File

@ -33,19 +33,19 @@
#include "nvim/vim.h"
static const char e_cannot_mix_positional_and_non_positional_str[]
= N_("E1400: Cannot mix positional and non-positional arguments: %s");
= N_("E1500: Cannot mix positional and non-positional arguments: %s");
static const char e_fmt_arg_nr_unused_str[]
= N_("E1401: format argument %d unused in $-style format: %s");
= N_("E1501: format argument %d unused in $-style format: %s");
static const char e_positional_num_field_spec_reused_str_str[]
= N_("E1402: Positional argument %d used as field width reused as different type: %s/%s");
= N_("E1502: Positional argument %d used as field width reused as different type: %s/%s");
static const char e_positional_nr_out_of_bounds_str[]
= N_("E1403: Positional argument %d out of bounds: %s");
= N_("E1503: Positional argument %d out of bounds: %s");
static const char e_positional_arg_num_type_inconsistent_str_str[]
= N_("E1404: Positional argument %d type used inconsistently: %s/%s");
= N_("E1504: Positional argument %d type used inconsistently: %s/%s");
static const char e_invalid_format_specifier_str[]
= N_("E1405: Invalid format specifier: %s");
= N_("E1505: Invalid format specifier: %s");
static const char e_aptypes_is_null_nr_str[]
= "E1408: Internal error: ap_types or ap_types[idx] is NULL: %d: %s";
= "E1520: Internal error: ap_types or ap_types[idx] is NULL: %d: %s";
static const char typename_unknown[] = N_("unknown");
static const char typename_int[] = N_("int");

View File

@ -107,65 +107,65 @@ func Test_printf_pos_misc()
call CheckLegacyAndVim9Failure(["call printf('%1$d%2$d', 1, 3, 4)"], "E767:")
call CheckLegacyAndVim9Failure(["call printf('%2$d%d', 1, 3)"], "E1400:")
call CheckLegacyAndVim9Failure(["call printf('%d%2$d', 1, 3)"], "E1400:")
call CheckLegacyAndVim9Failure(["call printf('%2$*1$d%d', 1, 3)"], "E1400:")
call CheckLegacyAndVim9Failure(["call printf('%d%2$*1$d', 1, 3)"], "E1400:")
call CheckLegacyAndVim9Failure(["call printf('%2$.*1$d%d', 1, 3)"], "E1400:")
call CheckLegacyAndVim9Failure(["call printf('%d%2$.*1$d', 1, 3)"], "E1400:")
call CheckLegacyAndVim9Failure(["call printf('%1$%')"], "E1400:")
call CheckLegacyAndVim9Failure(["call printf('%1$')"], "E1400:")
call CheckLegacyAndVim9Failure(["call printf('%1$_')"], "E1400:")
call CheckLegacyAndVim9Failure(["call printf('%1$*3$.*d', 3)"], "E1400:")
call CheckLegacyAndVim9Failure(["call printf('%1$*.*2$d', 3)"], "E1400:")
call CheckLegacyAndVim9Failure(["call printf('%1$*.*d', 3)"], "E1400:")
call CheckLegacyAndVim9Failure(["call printf('%*.*1$d', 3)"], "E1400:")
call CheckLegacyAndVim9Failure(["call printf('%*1$.*d', 3)"], "E1400:")
call CheckLegacyAndVim9Failure(["call printf('%*1$.*1$d', 3)"], "E1400:")
call CheckLegacyAndVim9Failure(["call printf('%2$d%d', 1, 3)"], "E1500:")
call CheckLegacyAndVim9Failure(["call printf('%d%2$d', 1, 3)"], "E1500:")
call CheckLegacyAndVim9Failure(["call printf('%2$*1$d%d', 1, 3)"], "E1500:")
call CheckLegacyAndVim9Failure(["call printf('%d%2$*1$d', 1, 3)"], "E1500:")
call CheckLegacyAndVim9Failure(["call printf('%2$.*1$d%d', 1, 3)"], "E1500:")
call CheckLegacyAndVim9Failure(["call printf('%d%2$.*1$d', 1, 3)"], "E1500:")
call CheckLegacyAndVim9Failure(["call printf('%1$%')"], "E1500:")
call CheckLegacyAndVim9Failure(["call printf('%1$')"], "E1500:")
call CheckLegacyAndVim9Failure(["call printf('%1$_')"], "E1500:")
call CheckLegacyAndVim9Failure(["call printf('%1$*3$.*d', 3)"], "E1500:")
call CheckLegacyAndVim9Failure(["call printf('%1$*.*2$d', 3)"], "E1500:")
call CheckLegacyAndVim9Failure(["call printf('%1$*.*d', 3)"], "E1500:")
call CheckLegacyAndVim9Failure(["call printf('%*.*1$d', 3)"], "E1500:")
call CheckLegacyAndVim9Failure(["call printf('%*1$.*d', 3)"], "E1500:")
call CheckLegacyAndVim9Failure(["call printf('%*1$.*1$d', 3)"], "E1500:")
call CheckLegacyAndVim9Failure(["call printf('%2$d', 3, 3)"], "E1401:")
call CheckLegacyAndVim9Failure(["call printf('%2$d', 3, 3)"], "E1501:")
call CheckLegacyAndVim9Failure(["call printf('%2$*1$d %1$ld', 3, 3)"], "E1402:")
call CheckLegacyAndVim9Failure(["call printf('%1$s %1$*1$d', 3)"], "E1402:")
call CheckLegacyAndVim9Failure(["call printf('%1$p %1$*1$d', 3)"], "E1402:")
call CheckLegacyAndVim9Failure(["call printf('%1$f %1$*1$d', 3)"], "E1402:")
call CheckLegacyAndVim9Failure(["call printf('%1$lud %1$*1$d', 3)"], "E1402:")
call CheckLegacyAndVim9Failure(["call printf('%1$llud %1$*1$d', 3)"], "E1402:")
call CheckLegacyAndVim9Failure(["call printf('%1$lld %1$*1$d', 3)"], "E1402:")
call CheckLegacyAndVim9Failure(["call printf('%1$s %1$*1$d', 3)"], "E1402:")
call CheckLegacyAndVim9Failure(["call printf('%1$c %1$*1$d', 3)"], "E1402:")
call CheckLegacyAndVim9Failure(["call printf('%1$ld %1$*1$d', 3)"], "E1402:")
call CheckLegacyAndVim9Failure(["call printf('%1$ld %2$*1$d', 3, 3)"], "E1402:")
call CheckLegacyAndVim9Failure(["call printf('%1$*1$ld', 3)"], "E1402:")
call CheckLegacyAndVim9Failure(["call printf('%1$*1$.*1$ld', 3)"], "E1402:")
call CheckLegacyAndVim9Failure(["call printf('%2$*1$d %1$ld', 3, 3)"], "E1502:")
call CheckLegacyAndVim9Failure(["call printf('%1$s %1$*1$d', 3)"], "E1502:")
call CheckLegacyAndVim9Failure(["call printf('%1$p %1$*1$d', 3)"], "E1502:")
call CheckLegacyAndVim9Failure(["call printf('%1$f %1$*1$d', 3)"], "E1502:")
call CheckLegacyAndVim9Failure(["call printf('%1$lud %1$*1$d', 3)"], "E1502:")
call CheckLegacyAndVim9Failure(["call printf('%1$llud %1$*1$d', 3)"], "E1502:")
call CheckLegacyAndVim9Failure(["call printf('%1$lld %1$*1$d', 3)"], "E1502:")
call CheckLegacyAndVim9Failure(["call printf('%1$s %1$*1$d', 3)"], "E1502:")
call CheckLegacyAndVim9Failure(["call printf('%1$c %1$*1$d', 3)"], "E1502:")
call CheckLegacyAndVim9Failure(["call printf('%1$ld %1$*1$d', 3)"], "E1502:")
call CheckLegacyAndVim9Failure(["call printf('%1$ld %2$*1$d', 3, 3)"], "E1502:")
call CheckLegacyAndVim9Failure(["call printf('%1$*1$ld', 3)"], "E1502:")
call CheckLegacyAndVim9Failure(["call printf('%1$*1$.*1$ld', 3)"], "E1502:")
call CheckLegacyAndVim9Failure(["call printf('%1$d%2$d', 3)"], "E1403:")
call CheckLegacyAndVim9Failure(["call printf('%1$d%2$d', 3)"], "E1503:")
call CheckLegacyAndVim9Failure(["call printf('%1$d %1$s', 3)"], "E1404:")
call CheckLegacyAndVim9Failure(["call printf('%1$ld %1$s', 3)"], "E1404:")
call CheckLegacyAndVim9Failure(["call printf('%1$ud %1$d', 3)"], "E1404:")
call CheckLegacyAndVim9Failure(["call printf('%1$s %1$f', 3.0)"], "E1404:")
call CheckLegacyAndVim9Failure(["call printf('%1$*1$d %1$ld', 3)"], "E1404:")
call CheckLegacyAndVim9Failure(["call printf('%1$s %1$d', 3)"], "E1404:")
call CheckLegacyAndVim9Failure(["call printf('%1$p %1$d', 3)"], "E1404:")
call CheckLegacyAndVim9Failure(["call printf('%1$f %1$d', 3)"], "E1404:")
call CheckLegacyAndVim9Failure(["call printf('%1$lud %1$d', 3)"], "E1404:")
call CheckLegacyAndVim9Failure(["call printf('%1$llud %1$d', 3)"], "E1404:")
call CheckLegacyAndVim9Failure(["call printf('%1$lld %1$d', 3)"], "E1404:")
call CheckLegacyAndVim9Failure(["call printf('%1$s %1$d', 3)"], "E1404:")
call CheckLegacyAndVim9Failure(["call printf('%1$c %1$d', 3)"], "E1404:")
call CheckLegacyAndVim9Failure(["call printf('%1$ld %1$d', 3)"], "E1404:")
call CheckLegacyAndVim9Failure(["call printf('%1$d %1$s', 3)"], "E1504:")
call CheckLegacyAndVim9Failure(["call printf('%1$ld %1$s', 3)"], "E1504:")
call CheckLegacyAndVim9Failure(["call printf('%1$ud %1$d', 3)"], "E1504:")
call CheckLegacyAndVim9Failure(["call printf('%1$s %1$f', 3.0)"], "E1504:")
call CheckLegacyAndVim9Failure(["call printf('%1$*1$d %1$ld', 3)"], "E1504:")
call CheckLegacyAndVim9Failure(["call printf('%1$s %1$d', 3)"], "E1504:")
call CheckLegacyAndVim9Failure(["call printf('%1$p %1$d', 3)"], "E1504:")
call CheckLegacyAndVim9Failure(["call printf('%1$f %1$d', 3)"], "E1504:")
call CheckLegacyAndVim9Failure(["call printf('%1$lud %1$d', 3)"], "E1504:")
call CheckLegacyAndVim9Failure(["call printf('%1$llud %1$d', 3)"], "E1504:")
call CheckLegacyAndVim9Failure(["call printf('%1$lld %1$d', 3)"], "E1504:")
call CheckLegacyAndVim9Failure(["call printf('%1$s %1$d', 3)"], "E1504:")
call CheckLegacyAndVim9Failure(["call printf('%1$c %1$d', 3)"], "E1504:")
call CheckLegacyAndVim9Failure(["call printf('%1$ld %1$d', 3)"], "E1504:")
call CheckLegacyAndVim9Failure(["call printf('%1$.2$d', 3)"], "E1405:")
call CheckLegacyAndVim9Failure(["call printf('%01$d', 3)"], "E1405:")
call CheckLegacyAndVim9Failure(["call printf('%01$0d', 3)"], "E1405:")
call CheckLegacyAndVim9Failure(["call printf('%1$*2d', 3)"], "E1405:")
call CheckLegacyAndVim9Failure(["call printf('%1$*3.*2$d', 3)"], "E1405:")
call CheckLegacyAndVim9Failure(["call printf('%1$*3$.2$d', 3)"], "E1405:")
call CheckLegacyAndVim9Failure(["call printf('%1$*3$.*2d', 3)"], "E1405:")
call CheckLegacyAndVim9Failure(["call printf('%1$1$.5d', 5)"], "E1405:")
call CheckLegacyAndVim9Failure(["call printf('%1$5.1$d', 5)"], "E1405:")
call CheckLegacyAndVim9Failure(["call printf('%1$1$.1$d', 5)"], "E1405:")
call CheckLegacyAndVim9Failure(["call printf('%1$.2$d', 3)"], "E1505:")
call CheckLegacyAndVim9Failure(["call printf('%01$d', 3)"], "E1505:")
call CheckLegacyAndVim9Failure(["call printf('%01$0d', 3)"], "E1505:")
call CheckLegacyAndVim9Failure(["call printf('%1$*2d', 3)"], "E1505:")
call CheckLegacyAndVim9Failure(["call printf('%1$*3.*2$d', 3)"], "E1505:")
call CheckLegacyAndVim9Failure(["call printf('%1$*3$.2$d', 3)"], "E1505:")
call CheckLegacyAndVim9Failure(["call printf('%1$*3$.*2d', 3)"], "E1505:")
call CheckLegacyAndVim9Failure(["call printf('%1$1$.5d', 5)"], "E1505:")
call CheckLegacyAndVim9Failure(["call printf('%1$5.1$d', 5)"], "E1505:")
call CheckLegacyAndVim9Failure(["call printf('%1$1$.1$d', 5)"], "E1505:")
endfunc
func Test_printf_pos_float()
@ -296,9 +296,9 @@ func Test_printf_pos_errors()
call CheckLegacyAndVim9Failure(['echo printf("%1$d", [])'], 'E745:')
call CheckLegacyAndVim9Failure(['echo printf("%1$d", 1, 2)'], 'E767:')
call CheckLegacyAndVim9Failure(['echo printf("%*d", 1)'], 'E766:')
call CheckLegacyAndVim9Failure(['echo printf("%1$s")'], 'E1403:')
call CheckLegacyAndVim9Failure(['echo printf("%1$s")'], 'E1503:')
call CheckLegacyAndVim9Failure(['echo printf("%1$d", 1.2)'], 'E805:')
call CheckLegacyAndVim9Failure(['echo printf("%1$f")'], 'E1403:')
call CheckLegacyAndVim9Failure(['echo printf("%1$f")'], 'E1503:')
endfunc
func Test_printf_pos_64bit()