expr-lang/expr

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

wodeqiangne opened this issue · 0 comments

`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)