Skip to content

Commit 3925c88

Browse files
committed
fixed parse error for white space in function argument list. syngan/vim-vimlint#62
1 parent fd899ab commit 3925c88

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

autoload/vimlparser.vim

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,12 +1229,14 @@ function! s:VimLParser.parse_cmd_function()
12291229
let varnode.pos = token.pos
12301230
let varnode.value = token.value
12311231
call add(node.rlist, varnode)
1232-
" XXX: Vim doesn't skip white space before comma. F(a ,b) => E475
1233-
if s:iswhite(self.reader.p(0))
1234-
throw s:Err(printf('unexpected token: %s', self.reader.p(0)), self.reader.getpos())
1235-
endif
1232+
let pc = self.reader.p(0)
1233+
let ppos = self.reader.getpos()
12361234
let token = tokenizer.get()
12371235
if token.type == s:TOKEN_COMMA
1236+
" XXX: Vim doesn't skip white space before comma. F(a ,b) => E475
1237+
if s:iswhite(pc)
1238+
throw s:Err('E475: Invalid argument: White space is not allowed before comma', ppos)
1239+
endif
12381240
" XXX: Vim allows last comma. F(a, b, ) => OK
12391241
if tokenizer.peek().type == s:TOKEN_PCLOSE
12401242
call tokenizer.get()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
vimlparser: unexpected token: : line 1 col 13
1+
vimlparser: E475: Invalid argument: White space is not allowed before comma: line 19 col 14
Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,20 @@
1-
function F(a ,b)
1+
function OK1(a)
2+
endfunction
3+
function OK2( a)
4+
endfunction
5+
function OK3(a )
6+
endfunction
7+
function OK4( a )
8+
endfunction
9+
function OK5(a,b)
10+
endfunction
11+
function OK6(a, b)
12+
endfunction
13+
function OK7( a, b)
14+
endfunction
15+
function OK8(a, b )
16+
endfunction
17+
function OK9( a, b )
18+
endfunction
19+
function NG(a ,b)
220
endfunction

0 commit comments

Comments
 (0)