From 75b1bab16f2ac899e95962b50e50344ceaf3deca Mon Sep 17 00:00:00 2001 From: pmqueiroz Date: Tue, 10 Dec 2024 23:59:38 -0300 Subject: [PATCH] fix: prevent range to return unknown type --- interpreter/eval.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/interpreter/eval.go b/interpreter/eval.go index f714802..5c6ca21 100644 --- a/interpreter/eval.go +++ b/interpreter/eval.go @@ -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 {