Skip to content

Commit 4f53b79

Browse files
committed
patch 8.2.2481: Vim9: confusing error when variable arguments have default
Problem: Vim9: confusing error when variable arguments have a default value. Solution: Give a specific error message. (closes #7793)
1 parent c3fc75d commit 4f53b79

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

src/testdir/test_vim9_func.vim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,16 @@ def Test_call_def_varargs()
781781
Func(1, 'a')
782782
END
783783
CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch')
784+
785+
lines =<< trim END
786+
vim9script
787+
def Func( # some comment
788+
...l = []
789+
)
790+
echo l
791+
enddef
792+
END
793+
CheckScriptFailure(lines, 'E1160:')
784794
enddef
785795

786796
let s:value = ''

src/userfunc.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@ get_function_args(
241241
skip);
242242
if (p == arg)
243243
break;
244+
if (*skipwhite(p) == '=')
245+
{
246+
emsg(_(e_cannot_use_default_for_variable_arguments));
247+
break;
248+
}
244249
}
245250
}
246251
else

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2481,
753755
/**/
754756
2480,
755757
/**/

0 commit comments

Comments
 (0)