expr-lang / expr

Expression language and expression evaluation for Go
https://expr-lang.org
MIT License
6.35k stars 408 forks source link

pass nil to interface method get runtime error "Call using interface {} as type *int (1:5)" #688

Open wodeqiangne opened 4 months ago

wodeqiangne commented 4 months ago

`type Foo interface { Add(a int, b *int) }

type FooImpl struct { }

func (FooImpl) Add(a int, b int) { return }

func TestNoInterfaceMethodWithNil(t *testing.T) {

var m = map[string]any{
    "foo": &FooImpl{},
}

program, err := expr.Compile(`foo.Add(1, nil)`)
require.NoError(t, err)

_, err = expr.Run(program, m)
require.NoError(t, err)

} `

return with error Call using interface {} as type *int (1:5)