Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot edit Go Map through pointer #308

Open
SolarLune opened this issue Jan 8, 2025 · 0 comments
Open

Cannot edit Go Map through pointer #308

SolarLune opened this issue Jan 8, 2025 · 0 comments

Comments

@SolarLune
Copy link

SolarLune commented Jan 8, 2025

Somewhat related to one of the previous issues I reported, it's not possible currently to set a key on a Go map made accessible through a pointer:

package main

import (
	"context"
	"fmt"

	"github.com/risor-io/risor"
)

func main() {

	data := map[string]any{
		"A": 1,
	}

	src := `
	data["B"] = 2
	print(data) // Prints {"A": 1, "B": 2}
	`

	_, err := risor.Eval(context.Background(), src, risor.WithGlobal("data", &data))
	if err != nil {
		fmt.Println(err)
	}

	fmt.Println(data) // Prints just map[A:1]

}

Should result in

{"A": 1, "B": 2}
map[A:1, B:2]

But instead just results in

{"A": 1, "B": 2}
map[A:1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant