-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Labels
enhancementNew feature or requestNew feature or request
Description
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.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request