Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iterating over nil (null) slices lead to an error #3608

Open
carpawell opened this issue Oct 11, 2024 · 0 comments
Open

Iterating over nil (null) slices lead to an error #3608

carpawell opened this issue Oct 11, 2024 · 0 comments
Labels
bug Something isn't working compiler Go smart contract compiler I4 No visible changes S4 Routine U2 Seriously planned

Comments

@carpawell
Copy link
Member

Nil slice iteration (no-op) looks natural in GO but did not work for me in the contract.

Current Behavior

func hi(t []int) {
    for i, replica := range t {
		storage.Put(ctx, []byte{byte(i)}, replica)
	}
}

Lead to at instruction 4754 (SIZE): invalid conversion: Null/ByteString if i pass nil to Invoker. NOTE: I did not deploy the contract, just tested it in neofs-contracts: https://github.com/nspcc-dev/neofs-contract/blob/a8d5e001a2e5a552676eecd40ef78629ecdfafa2/tests/container_test.go
Maybe that is important.

Expected Behavior

Just skipping for.

Possible Solution

Change compiler code?

Steps to Reproduce

Try to compile and call the code from Current Behavior.

Context

nspcc-dev/neofs-contract#438

Regression

Not sure.

Your Environment

github.com/nspcc-dev/neo-go v0.106.3

@carpawell carpawell added bug Something isn't working compiler Go smart contract compiler U2 Seriously planned labels Oct 11, 2024
@roman-khimov roman-khimov added S4 Routine I4 No visible changes labels Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler Go smart contract compiler I4 No visible changes S4 Routine U2 Seriously planned
Projects
None yet
Development

No branches or pull requests

2 participants