From 3535927bcd01bc95e215918f1e2060c8d6a822c7 Mon Sep 17 00:00:00 2001 From: yuyi Date: Mon, 13 Jun 2022 01:29:54 +0800 Subject: [PATCH] parser: correct error message for seclector_expr_assign.vv (#14747) --- vlib/v/checker/tests/selector_expr_assign.out | 4 ++-- vlib/v/parser/assign.v | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vlib/v/checker/tests/selector_expr_assign.out b/vlib/v/checker/tests/selector_expr_assign.out index 9e98006788..ac45490a1c 100644 --- a/vlib/v/checker/tests/selector_expr_assign.out +++ b/vlib/v/checker/tests/selector_expr_assign.out @@ -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() { 6 | abc := Abc{} 7 | abc.a := 2 - | ^ + | ~~ 8 | } diff --git a/vlib/v/parser/assign.v b/vlib/v/parser/assign.v index 0c3ab4cfe8..6b3b7f193b 100644 --- a/vlib/v/parser/assign.v +++ b/vlib/v/parser/assign.v @@ -244,8 +244,8 @@ fn (mut p Parser) partial_assign_stmt(left []ast.Expr, left_comments []ast.Comme ast.PrefixExpr {} ast.SelectorExpr { if op == .decl_assign { - return p.error_with_pos('struct fields can only be declared during the initialization', - lx.pos) + return p.error_with_pos('use assignment `=` instead of declaration `:=` when modifying struct fields', + pos) } } else {