Accessing the structure field in the slice fails with panic #1553

Open
opened 2025-12-28 17:16:49 +00:00 by sami · 0 comments
Owner

Originally created by @Turalchik on GitHub (Sep 16, 2025).

func TestBla(t *testing.T) {
	src := `package main
    type nested struct{ t int }
	type test struct{ a []nested }
	
	func Main() int {
		var myStruct = test{a: make([]nested, 1)}
		return myStruct.a[0].t
	}`
	eval(t, src, big.NewInt(1))
}

Current Behavior

Test returns an error: at instruction 15 (PICKITEM): invalid conversion: Null/ByteString.

Expected Behavior

Test should return 1.

Possible Solution

I think make() should fill the array not with stackitem.Null{}, but with zero values for each type.

Steps to Reproduce

Run the test above.

Your Environment

v0.112.0

Originally created by @Turalchik on GitHub (Sep 16, 2025). <!-- Provide a general summary of the issue in the Title above --> ```golang func TestBla(t *testing.T) { src := `package main type nested struct{ t int } type test struct{ a []nested } func Main() int { var myStruct = test{a: make([]nested, 1)} return myStruct.a[0].t }` eval(t, src, big.NewInt(1)) } ``` ## Current Behavior Test returns an error: `at instruction 15 (PICKITEM): invalid conversion: Null/ByteString`. ## Expected Behavior Test should return 1. ## Possible Solution I think `make()` should fill the array not with `stackitem.Null{}`, but with zero values for each type. ## Steps to Reproduce <!-- Provide a link to a live example, or an unambiguous set of steps to reproduce this bug. --> Run the test above. ## Your Environment <!-- Include as many relevant details about the environment you experienced the bug in --> v0.112.0
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nspcc-dev/neo-go#1553
No description provided.