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

Allow returns values to be ignored in try catch #1369

Merged
merged 1 commit into from
Jun 23, 2023

Conversation

seanyoung
Copy link
Contributor

@seanyoung seanyoung commented Jun 16, 2023

A try catch statement does not need to decode the return values if it is not interested.

interface I {
      function func()   externalpublic returns (int, bool);
}

contract C {
     function test(I i) public {
           try I.func() {
           }
           catch (bytes memory bs) { 
           }
     } 
}

Here func() returns two values but the try statement does not use them at all. This means they do not have abi decoded either.

@seanyoung seanyoung marked this pull request as ready for review June 16, 2023 21:19
Copy link
Contributor

@xermicus xermicus left a comment

Choose a reason for hiding this comment

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

I think this change is correct. A codegen test, ultimately proofing that the decoding is no longer happening, would be the cherry on top.

@seanyoung seanyoung requested a review from LucasSte June 21, 2023 14:25
A try catch statement does not need to decode the return values if it is not interested.

Signed-off-by: Sean Young <[email protected]>
@seanyoung
Copy link
Contributor Author

I think this change is correct. A codegen test, ultimately proofing that the decoding is no longer happening, would be the cherry on top.

I've added a test

@seanyoung seanyoung merged commit 8906a77 into hyperledger-solang:main Jun 23, 2023
@seanyoung seanyoung deleted the try branch June 23, 2023 12:52
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