Skip to content

Commit

Permalink
fix: prevent range to return unknown type
Browse files Browse the repository at this point in the history
  • Loading branch information
pmqueiroz committed Dec 11, 2024
1 parent 82a7e5d commit 75b1bab
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion interpreter/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,12 @@ func Evaluate(expression ast.Expression, env *environment.Environment) (interfac
case tokens.RANGE:
switch parsedRight := right.(type) {
case string:
return strings.Split(parsedRight, ""), nil
runes := []rune(parsedRight)
result := make([]interface{}, len(runes))
for i, r := range runes {
result[i] = string(r)
}
return result, nil
case map[interface{}]interface{}:
var result [][]interface{}
for key, value := range parsedRight {
Expand Down

0 comments on commit 75b1bab

Please sign in to comment.