Closed
Description
Thanks for the great library.
I experience a "strange" behavior.
package main
import (
"fmt"
"github.com/expr-lang/expr"
)
type Env struct {
A string
B *string
}
func main() {
code := `A == B`
program, err := expr.Compile(code, expr.Env(Env{}))
if err != nil {
panic(err)
}
value := "ok"
env := Env{
A: value,
B: &value,
}
output, err := expr.Run(program, env)
if err != nil {
panic(err)
}
fmt.Println(output)
}
Try in go playground .
I expect the output to be true but it is false.
Is this behavior intentional?
Reading another issue related to pointers I was with the impression that pointers
should be "hidden", since a lot of stakeholders are people who cannot code well.
changing the code to:
code := `A == (B ?? "")`
outputs true as expected.
Maybe this at least can be documented (if it's not already and I missed it) or
the comparison operator supports a comparison between strings and pointers to strings.
best