solidity icon indicating copy to clipboard operation
solidity copied to clipboard

Enrich document with using getter function over state struct instance

Open haoyang9804 opened this issue 1 year ago • 9 comments

Inspired by this issue: https://github.com/ethereum/solidity/issues/15525. I guess it's better to add a document for this special return type since it's truly confusing.

haoyang9804 avatar Oct 18 '24 21:10 haoyang9804

Thank you for your contribution to the Solidity compiler! A team member will follow up shortly.

If you haven't read our contributing guidelines and our review checklist before, please do it now, this makes the reviewing process and accepting your contribution smoother.

If you have any questions or need our help, feel free to post them in the PR or talk to us directly on the #solidity-dev channel on Matrix.

github-actions[bot] avatar Oct 18 '24 21:10 github-actions[bot]

Just a note on general structure here: the section on getters is already a bit too verbose IMO, with a lot of space and examples given to what are essentially obscure corner cases. I think we shouldn't make it even longer. We should consolidate the examples and make text more coherent. The focus should be kept primarily on explaining what getters are, the other things are just notes.

How about merging struct example and mapping example? They are all corner cases that can lead to confusion.

haoyang9804 avatar Oct 21 '24 14:10 haoyang9804

Yes, they should be consolidated IMO. We could have just one example showing them all. Or even just a general description of how the ABI for a getter looks like. Which is relevant e.g. when you want to override a function with a getter and should be mentioned too.

cameel avatar Oct 21 '24 14:10 cameel

Yes, they should be consolidated IMO. We could have just one example showing them all. Or even just a general description of how the ABI for a getter looks like. Which is relevant e.g. when you want to override a function with a getter and should be mentioned too.

Good suggestion. But I can only help with the consolidation part. I'm not very familiar with ABI.

haoyang9804 avatar Oct 21 '24 14:10 haoyang9804

I think the Complex example is useful for benefit users' understanding in getter function. Maybe we can remove this example and only leave examples of array and struct the mitigate confusion.

haoyang9804 avatar Oct 21 '24 16:10 haoyang9804

I think the Complex example is useful for benefit users' understanding in getter function. Maybe we can remove this example and only leave examples of array and struct the mitigate confusion.

I have merged the struct example and the array example. As for the Complex one that combine mapping and struct, since it implies no corner case, I removed it. As for the ABI part, I think I can submit another pr after gaining some background.

haoyang9804 avatar Oct 21 '24 17:10 haoyang9804

@cameel Hi Kamil, any suggestions on the new commit?

haoyang9804 avatar Oct 25 '24 08:10 haoyang9804

Thx for your review @matheusaaguiar, I have refined the doc, please take a look

haoyang9804 avatar Oct 25 '24 22:10 haoyang9804

Hi @matheusaaguiar , is it OK to merge?

haoyang9804 avatar Nov 04 '24 08:11 haoyang9804