Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions expr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2846,6 +2846,23 @@ func TestMemoryBudget(t *testing.T) {
}
}

func TestIssue802(t *testing.T) {
prog, err := expr.Compile(`arr[1:2][0]`)
if err != nil {
t.Fatalf("error compiling program: %v", err)
}
val, err := expr.Run(prog, map[string]any{
"arr": [5]int{0, 1, 2, 3, 4},
})
if err != nil {
t.Fatalf("error running program: %v", err)
}
valInt, ok := val.(int)
if !ok || valInt != 1 {
t.Fatalf("invalid result, expected 1, got %v", val)
}
}

func TestIssue807(t *testing.T) {
type MyStruct struct {
nonExported string
Expand Down
5 changes: 5 additions & 0 deletions vm/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ func Slice(array, from, to any) any {
if a > b {
a = b
}
if v.Kind() == reflect.Array && !v.CanAddr() {
newValue := reflect.New(v.Type()).Elem()
newValue.Set(v)
v = newValue
}
value := v.Slice(a, b)
if value.IsValid() {
return value.Interface()
Expand Down
Loading