expr icon indicating copy to clipboard operation
expr copied to clipboard

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

Open wodeqiangne opened this issue 1 year ago • 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)

wodeqiangne avatar Jul 23 '24 09:07 wodeqiangne