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:
parent
fae26197b9
commit
f8461e2b3c
@ -3364,6 +3364,9 @@ fn (mut p Parser) const_decl() ast.ConstDecl {
|
|||||||
pos)
|
pos)
|
||||||
}
|
}
|
||||||
full_name := p.prepend_mod(name)
|
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)
|
p.check(.assign)
|
||||||
end_comments << p.eat_comments()
|
end_comments << p.eat_comments()
|
||||||
if p.tok.kind == .key_fn {
|
if p.tok.kind == .key_fn {
|
||||||
|
7
vlib/v/parser/tests/const_decl_err.out
Normal file
7
vlib/v/parser/tests/const_decl_err.out
Normal 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 |
|
12
vlib/v/parser/tests/const_decl_err.vv
Normal file
12
vlib/v/parser/tests/const_decl_err.vv
Normal 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")
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user