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

checker: fix no error on plus-assigning array (fix #15544) (#15552)

This commit is contained in:
ChAoS_UnItY 2022-08-27 04:11:23 +08:00 committed by GitHub
parent f45042fa09
commit 70de4e1009
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

View File

@ -361,7 +361,7 @@ pub fn (mut c Checker) assign_stmt(mut node ast.AssignStmt) {
node.pos)
}
}
if left_sym.kind == .array && right_sym.kind == .array {
if left_sym.kind == .array && right_sym.kind == .array && node.op == .assign {
// `mut arr := [u8(1),2,3]`
// `arr = [byte(4),5,6]`
left_info := left_sym.info as ast.Array

View File

@ -0,0 +1,8 @@
vlib/v/checker/tests/array_plus_assign_err.vv:1:5: warning: unused variable: `buffer`
1 | mut buffer := []u8{cap: 1024}
| ~~~~~~
2 | buffer += "ipconfig && sudo apt-get install -y some_amazing_package name + command output".bytes()
vlib/v/checker/tests/array_plus_assign_err.vv:2:1: error: operator `+=` not defined on left operand type `[]u8`
1 | mut buffer := []u8{cap: 1024}
2 | buffer += "ipconfig && sudo apt-get install -y some_amazing_package name + command output".bytes()
| ~~~~~~

View File

@ -0,0 +1,2 @@
mut buffer := []u8{cap: 1024}
buffer += "ipconfig && sudo apt-get install -y some_amazing_package name + command output".bytes()