mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-04 19:02:28 +00:00
compiler: allow to use +=
on strings
This commit is contained in:
parent
fd7af77895
commit
59367c96d1
3 changed files with 24 additions and 11 deletions
|
@ -1440,7 +1440,11 @@ func (c *codegen) emitToken(tok token.Token, typ types.Type) {
|
|||
|
||||
func convertToken(tok token.Token, typ types.Type) (opcode.Opcode, error) {
|
||||
switch tok {
|
||||
case token.ADD_ASSIGN:
|
||||
case token.ADD_ASSIGN, token.ADD:
|
||||
// VM has separate opcodes for number and string concatenation
|
||||
if isString(typ) {
|
||||
return opcode.CAT, nil
|
||||
}
|
||||
return opcode.ADD, nil
|
||||
case token.SUB_ASSIGN:
|
||||
return opcode.SUB, nil
|
||||
|
@ -1450,12 +1454,6 @@ func convertToken(tok token.Token, typ types.Type) (opcode.Opcode, error) {
|
|||
return opcode.DIV, nil
|
||||
case token.REM_ASSIGN:
|
||||
return opcode.MOD, nil
|
||||
case token.ADD:
|
||||
// VM has separate opcodes for number and string concatenation
|
||||
if isString(typ) {
|
||||
return opcode.CAT, nil
|
||||
}
|
||||
return opcode.ADD, nil
|
||||
case token.SUB:
|
||||
return opcode.SUB, nil
|
||||
case token.MUL:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue