diff --git a/compiler/checker_expressions.go b/compiler/checker_expressions.go index 5c47a172d..356cbb44f 100644 --- a/compiler/checker_expressions.go +++ b/compiler/checker_expressions.go @@ -2166,7 +2166,7 @@ func (tc *typechecker) checkCompositeLiteral(node *ast.CompositeLiteral, typ ref var elemTi *typeInfo if cl, ok := kv.Value.(*ast.CompositeLiteral); ok { if ti.Type.Elem().Kind() == reflect.Ptr { - // The slice (or array) as element *T, so the value '{..}' must be + // The slice (or array) has element *T, so the value '{..}' must be // replaced with '&T{..}'. kv.Value = ast.NewUnaryOperator(cl.Pos(), ast.OperatorAddress, cl) tc.checkCompositeLiteral(cl, ti.Type.Elem().Elem()) // []*T -> T (or [n]*T -> T) diff --git a/compiler/parser.go b/compiler/parser.go index 51bf534f6..36476e6c9 100644 --- a/compiler/parser.go +++ b/compiler/parser.go @@ -895,7 +895,7 @@ LABEL: if a, ok := init.(*ast.Assignment); ok && a.Type == ast.AssignmentSimple { panic(syntaxError(tok.pos, "assignment %s used as value", init)) } - panic(syntaxError(tok.pos, "%s used as value", init)) + panic(syntaxError(tok.pos, "cannot use %s as value", init)) } init = nil } diff --git a/test/compare/testdata/syntax/if_statement.go b/test/compare/testdata/syntax/if_statement.go index 8343bbcb4..7f259e0b7 100644 --- a/test/compare/testdata/syntax/if_statement.go +++ b/test/compare/testdata/syntax/if_statement.go @@ -44,12 +44,12 @@ func main() { if f() {} if <-ch {} // ERROR `non-bool <-ch (type int) used as if condition` if <-chb {} - if ch <- 3 {} // ERROR `ch <- 3 used as value` - if i++ for {} // ERROR `syntax error: i++ used as value` - if i++ {} // ERROR `syntax error: i++ used as value` - if i-- {} // ERROR `syntax error: i-- used as value` + if ch <- 3 {} // ERROR `cannot use ch <- 3 as value` + if i++ for {} // ERROR `syntax error: cannot use i++ as value` + if i++ {} // ERROR `syntax error: cannot use i++ as value` + if i-- {} // ERROR `syntax error: cannot use i-- as value` if i = 3 {} // ERROR `syntax error: assignment i = 3 used as value` - if i := 3 { _ = i } // ERROR `syntax error: i := 3 used as value` + if i := 3 { _ = i } // ERROR `syntax error: cannot use i := 3 as value` if print(); {} // ERROR `syntax error: missing condition in if statement` if <-ch; {} // ERROR `syntax error: missing condition in if statement` if ch <- 3; {} // ERROR `syntax error: missing condition in if statement`