proc: correctly truncate the result of binary ops on integers (#2463)

Truncates the result of binary operations on integers to the size of
the resulting type.
Also rewrites convertInt to not require allocations.

Fixes #2454
This commit is contained in:
Alessandro Arzilli
2021-05-17 19:31:05 +02:00
committed by GitHub
parent db291698e0
commit 32946b2d7c
3 changed files with 42 additions and 12 deletions

View File

@ -836,6 +836,10 @@ func TestEvalExpression(t *testing.T) {
{`iface2map.(data)`, false, "…", "…", "map[string]interface {}", nil},
{"issue1578", false, "main.Block {cache: *main.Cache nil}", "main.Block {cache: *main.Cache nil}", "main.Block", nil},
{"ni8 << 2", false, "-20", "-20", "int8", nil},
{"ni8 << 8", false, "0", "0", "int8", nil},
{"ni8 >> 1", false, "-3", "-3", "int8", nil},
{"bytearray[0] * bytearray[0]", false, "144", "144", "uint8", nil},
}
ver, _ := goversion.Parse(runtime.Version())