Skip to content

Conversation

@connorwstein
Copy link
Contributor

@connorwstein connorwstein commented Dec 11, 2020

In this PR the template was changed which ended up producing code like:

	var out []interface{}
	err := _NonExistentStruct.contract.Call(opts, &out, "Struct")

	outstruct := new(struct {
		A *big.Int
		B *big.Int
	})

	outstruct.A = out[0].(*big.Int)
	outstruct.B = out[1].(*big.Int)

	return *outstruct, err

which will panic instead of returning an error if the contract doesn't exist. I moved the error handling up before the indexing to avoid that (analogous to how non-struct responses are handled)

Copy link
Member

@MariusVanDerWijden MariusVanDerWijden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for noticing, and adding a test 👍

@connorwstein
Copy link
Contributor Author

@MariusVanDerWijden thanks for the quick review. The build failure looks like a flake - would you be able to re-run? Don't think I have permissions to do that.

@MariusVanDerWijden
Copy link
Member

restarted

@holiman holiman changed the title Fix err handling in generated wrappers for functions returning structs abi/bind: fix error-handling in generated wrappers for functions returning structs Dec 12, 2020
@holiman holiman merged commit 38c1d59 into ethereum:master Dec 12, 2020
@holiman
Copy link
Contributor

holiman commented Dec 12, 2020

Thanks!

@holiman holiman added this to the 1.10.0 milestone Dec 12, 2020
@ian0371 ian0371 mentioned this pull request Dec 31, 2024
9 tasks
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 24, 2025
…rning structs (ethereum#22005)

Fixes the template used when generating code, which in some scenarios would lead to panic instead of returning an error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants