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

Parse error: Unexpected token for assignment: . for math on Go field #304

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

Comments

@SolarLune
Copy link

SolarLune commented Jan 7, 2025

Risor seems to have an issue performing either -= or += operations on numerical fields contained within Go structs, though it can assign them fine.

For example, this doesn't work:

package main

import (
	"context"

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

type Object struct {
	A int
}

func main() {

	src := "Object.A -= 1"

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

}

But this does:

package main

import (
	"context"

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

type Object struct {
	A int
}

func main() {

	src := "Object.A = Object.A - 1"

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

}

EDIT: This is probably tied to #307.

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