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

@ -33,6 +33,16 @@ var sliceTestCases = []testCase{
`,
big.NewInt(42),
},
{
"increase slice element with +=",
`package foo
func Main() int {
a := []int{1, 2, 3}
a[1] += 40
return a[1]
}`,
big.NewInt(42),
},
{
"complex test",
`