1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

parser: fix fn argument type position (#15102)

This commit is contained in:
yuyi 2022-07-17 15:55:20 +08:00 committed by GitHub
parent 3075e35237
commit 78242627c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 9 deletions

View File

@ -2,6 +2,6 @@ vlib/v/checker/tests/array_sort_with_compare_ref_elem_err.vv:21:23: error: sort_
19 | }
20 |
21 | fn sort_cells_by_yx(a &Cell, b &Cell) int {
| ^
| ~~~~~
22 | if a.pos.y == b.pos.y {
23 | if a.pos.x < b.pos.x {

View File

@ -1,5 +1,5 @@
vlib/v/checker/tests/fn_arg_of_optional_err.vv:1:19: error: optional type argument is not supported currently
1 | fn optional_arg(x ?int) {
| ^
| ~~~~
2 | println('int type: $x')
3 | }

View File

@ -9,7 +9,7 @@ vlib/sokol/audio/audio.v:101:19: error: struct `C.saudio_desc` was declared as p
99 |
100 | // setup - setup sokol-audio
101 | pub fn setup(desc &C.saudio_desc) {
| ^
| ~~~~~~~~~~~~~~
102 | C.saudio_setup(desc)
103 | }
vlib/sokol/audio/audio.v:121:16: error: struct `C.saudio_desc` was declared as private to module `module_with_redeclaration`, so it can not be used inside module `sokol.audio`

View File

@ -830,6 +830,7 @@ fn (mut p Parser) fn_args() ([]ast.Param, bool, bool) {
}
pos := p.tok.pos()
mut arg_type := p.parse_type()
type_pos := pos.extend(p.prev_tok.pos())
if arg_type == 0 {
// error is added in parse_type
return []ast.Param{}, false, false
@ -884,7 +885,7 @@ fn (mut p Parser) fn_args() ([]ast.Param, bool, bool) {
name: name
is_mut: is_mut
typ: arg_type
type_pos: pos
type_pos: type_pos
}
arg_no++
if arg_no > 1024 {
@ -940,6 +941,7 @@ fn (mut p Parser) fn_args() ([]ast.Param, bool, bool) {
}
pos := p.tok.pos()
mut typ := p.parse_type()
type_pos[0] = pos.extend(p.prev_tok.pos())
if typ == 0 {
// error is added in parse_type
return []ast.Param{}, false, false