Skip to content

Array's items swap compiles but does not work as expected #3611

@carpawell

Description

@carpawell

Another hour of debug.

Current Behavior

    arr := []byte{1, 0}
    arr[0], arr[1] = arr[1], arr[0]

compiles ok. I get {0, 0}

Expected Behavior

... but want to get {0, 1}

Possible Solution

  1. Do not allow such code
  2. Make swap with the third var as it is done in many languages (e.g. go)

Steps to Reproduce

Code from Current Behavior

Context

nspcc-dev/neofs-contract#438

Regression

Not sure

Your Environment

github.com/nspcc-dev/neo-go v0.106.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    I4No visible changesS4RoutineU2Seriously plannedbugSomething isn't workingcompilerGo smart contract compiler

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions