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

parser: check const declaration using multiple assign (#14886)

This commit is contained in:
yuyi 2022-06-29 17:03:56 +08:00 committed by GitHub
parent fae26197b9
commit f8461e2b3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

View File

@ -3364,6 +3364,9 @@ fn (mut p Parser) const_decl() ast.ConstDecl {
pos)
}
full_name := p.prepend_mod(name)
if p.tok.kind == .comma {
p.error_with_pos('const declaration do not support multiple assign yet', p.tok.pos())
}
p.check(.assign)
end_comments << p.eat_comments()
if p.tok.kind == .key_fn {

View File

@ -0,0 +1,7 @@
vlib/v/parser/tests/const_decl_err.vv:6:3: error: const declaration do not support multiple assign yet
4 |
5 | const (
6 | a, b, c = foo()
| ^
7 | )
8 |

View File

@ -0,0 +1,12 @@
fn foo() (int, int, int) {
return 1, 2, 3
}
const (
a, b, c = foo()
)
fn main() {
println("$a $b $c")
}