parser: correct error message for seclector_expr_assign.vv (#14747)
parent
139c34c07d
commit
3535927bcd
|
@ -1,6 +1,6 @@
|
||||||
vlib/v/checker/tests/selector_expr_assign.vv:7:6: error: struct fields can only be declared during the initialization
|
vlib/v/checker/tests/selector_expr_assign.vv:7:8: error: use assignment `=` instead of declaration `:=` when modifying struct fields
|
||||||
5 | fn main() {
|
5 | fn main() {
|
||||||
6 | abc := Abc{}
|
6 | abc := Abc{}
|
||||||
7 | abc.a := 2
|
7 | abc.a := 2
|
||||||
| ^
|
| ~~
|
||||||
8 | }
|
8 | }
|
||||||
|
|
|
@ -244,8 +244,8 @@ fn (mut p Parser) partial_assign_stmt(left []ast.Expr, left_comments []ast.Comme
|
||||||
ast.PrefixExpr {}
|
ast.PrefixExpr {}
|
||||||
ast.SelectorExpr {
|
ast.SelectorExpr {
|
||||||
if op == .decl_assign {
|
if op == .decl_assign {
|
||||||
return p.error_with_pos('struct fields can only be declared during the initialization',
|
return p.error_with_pos('use assignment `=` instead of declaration `:=` when modifying struct fields',
|
||||||
lx.pos)
|
pos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue