compiler: allow using OP= with struct fields and slice elements

Do it in a generic way, there is no need in restricting to only
variables.
Port of #954.
This commit is contained in:
Evgenii Stratonikov 2020-05-18 11:45:20 +03:00
parent fdb217ec81
commit 1b105a9f1d
3 changed files with 40 additions and 15 deletions

View file

@ -134,6 +134,17 @@ var structTestCases = []testCase{
}`,
big.NewInt(14),
},
{
"increase struct field with +=",
`package foo
type token struct { x int }
func Main() int {
t := token{x: 2}
t.x += 3
return t.x
}`,
big.NewInt(5),
},
{
"assign a struct field to a struct field",
`