diff --git a/pkg/vm/compiler/codegen.go b/pkg/vm/compiler/codegen.go index 8a1ceb622..60c6bf081 100644 --- a/pkg/vm/compiler/codegen.go +++ b/pkg/vm/compiler/codegen.go @@ -372,14 +372,26 @@ func (c *codegen) Visit(node ast.Node) ast.Visitor { // example: // const x = 10 // x + 2 will results into 12 - if tinfo := c.typeInfo.Types[n]; tinfo.Value != nil { + tinfo := c.typeInfo.Types[n] + if tinfo.Value != nil { c.emitLoadConst(tinfo) return nil } ast.Walk(c, n.X) ast.Walk(c, n.Y) - c.convertToken(n.Op) + + // VM has separate opcode for string concatenation + if n.Op == token.ADD { + typ, ok := tinfo.Type.Underlying().(*types.Basic) + if ok && typ.Kind() == types.String { + emitOpcode(c.prog, vm.CAT) + } else { + emitOpcode(c.prog, vm.ADD) + } + } else { + c.convertToken(n.Op) + } return nil }