The desugaring pass should be updated to desugar for range loops over strings:
var s string
for range string { ... }
for index := range string { ... }
for index, rune := range string { ... }
At first glance it should simply be a matter of adding *types.Basic (with .Kind() == types.String) to the case where we handle *types.Array and *types.Slice here, however range loops are a bit different when strings are involved. When indexing a string you get back a byte. When using a for range loop with a string you get a rune along with an index representing its offset in the string. More info in https://go.dev/blog/strings.
The desugaring pass should use utf.DecodeRuneInString to parse runes from strings iteratively.
The desugaring pass should be updated to desugar for range loops over strings:
At first glance it should simply be a matter of adding
*types.Basic(with.Kind() == types.String) to the case where we handle*types.Arrayand*types.Slicehere, however range loops are a bit different when strings are involved. When indexing a string you get back abyte. When using a for range loop with a string you get arunealong with an index representing its offset in the string. More info in https://go.dev/blog/strings.The desugaring pass should use
utf.DecodeRuneInStringto parse runes from strings iteratively.