nspcc-dev / neo-go

Go Node and SDK for the Neo blockchain
MIT License
124 stars 79 forks source link

Support ranging over integers in compiler #3525

Open roman-khimov opened 3 months ago

roman-khimov commented 3 months ago

Is your feature request related to a problem? Please describe.

Go 1.22 feature:

       {
               "range",
               `func F%d() int {
                       sum := 0
                       arr := []int{1, 2, 3}
                       for i := range 3 {
                               sum += arr[i] 
                       }
                       return sum
               }
               `,
               big.NewInt(6),
       },

leads to

                                --- Expected
                                +++ Actual
                                @@ -3,3 +3,3 @@
                                  abs: (big.nat) (len=1) {
                                -  (big.Word) 6
                                +  (big.Word) 1
                                  }

Describe the solution you'd like

Add support for it.

AnnaShaleva commented 3 weeks ago

And update example contracts, ref. https://github.com/nspcc-dev/neo-go/pull/3605#discussion_r1793761361.