-
-
Notifications
You must be signed in to change notification settings - Fork 464
Closed
Description
Good day everyone!
The documentation says that foo.bar and foo["bar"] are equivalent, but they're not. The parser doesn't expect foo["bar"] (), while it might expect foo.bar().
package main
import (
"fmt"
"github.com/expr-lang/expr"
)
func main() {
env := struct{ foo struct{ fn func() string } }{
foo: struct{ fn func() string }{
fn: func() string { return "baar" },
},
}
_, err := expr.Compile(`foo.fn()`, expr.Env(env), expr.Optimize(true))
fmt.Println(err)
_, err = expr.Compile(`foo["fn"]()`, expr.Env(env), expr.Optimize(true))
fmt.Println(err)
// Output:
// <nil>
// unexpected token Bracket("(") (1:10)
// | foo["fn"]()
// | .........^
}
Metadata
Metadata
Assignees
Labels
No labels