solidity icon indicating copy to clipboard operation
solidity copied to clipboard

Update inheritance.rst typo

Open qazawatzirak opened this issue 2 years ago • 1 comments

  • The order of events thrown is Final - Base2 - Base1 - Emittable
  • Discussion is here: https://ethereum.stackexchange.com/questions/166285/inheritance-chain-and-super-keyword

qazawatzirak avatar Oct 16 '24 14:10 qazawatzirak

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 16 '24 14:10 github-actions[bot]

I think this is a misunderstanding. The text in the docs shows a problematic use of calling a function from a base by explicitly specifying the contract (Base2.emitEvent). In this case, the contract Base1 in the inheritance hierarchy is skipped and the resulting sequence of events will not contain Base1Emitted. After that, the text then presents the proper way of avoiding the problem, by using super instead, which then calls the function on the next base contract and so on and so forth. Now, Final will call Base2 which in turn will call Base1 that was missing on the previous example. That's the reason the text says that it will call Base1.emitEvent(). Because, now super ensures that the inheritance hierarchy is properly followed instead of having the direct call to Base2 bypass the call to Base1.

matheusaaguiar avatar Oct 29 '24 22:10 matheusaaguiar