compiler: do not enforce variadic event args check on ellipsis usage
In case of ellipsis usage compiler defines argument type as ArrayT (which is correct, because it's a natural representation of the last argument, it represents the array of interface{}). Here goes the problem: ``` === RUN TestEventWarnings/variadic_event_args_via_ellipsis compiler_test.go:251: Error Trace: compiler_test.go:251 Error: Received unexpected error: event 'Event' should have 'Integer' as type of 1 parameter, got: Array Test: TestEventWarnings/variadic_event_args_via_ellipsis ``` Parsing the last argument in this case is a separate complicated problem due to the fact that we need to grab types of elements of []interface{} inside the fully qualified ast node which may looks like: ``` runtime.Notify("Event", (append([]interface{}{1, 2}, (([]interface{}{someVar, 4}))...))...) ``` Temporary solution is to exclude such notifications from analysis until we're able to properly resolve element types of []interface{}.
This commit is contained in:
parent
08427f23b6
commit
80f71a4e6e
2 changed files with 27 additions and 7 deletions
|
@ -230,6 +230,25 @@ func TestEventWarnings(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
})
|
||||
})
|
||||
t.Run("variadic event args via ellipsis", func(t *testing.T) {
|
||||
src := `package payable
|
||||
import "github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||
func Main() {
|
||||
runtime.Notify("Event", []interface{}{1}...)
|
||||
}`
|
||||
|
||||
_, di, err := compiler.CompileWithOptions("eventTest.go", strings.NewReader(src), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = compiler.CreateManifest(di, &compiler.Options{
|
||||
Name: "eventTest",
|
||||
ContractEvents: []manifest.Event{{
|
||||
Name: "Event",
|
||||
Parameters: []manifest.Parameter{manifest.NewParameter("number", smartcontract.IntegerType)},
|
||||
}},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
func TestNotifyInVerify(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue