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

Fix UnimplementedFeatureError for Custom Errors in Require Statements #15245

Closed
wants to merge 1 commit into from

Conversation

tal7aouy
Copy link

@tal7aouy tal7aouy commented Jul 6, 2024

This pull request addresses the UnimplementedFeatureError encountered when using a custom error with the require statement in Solidity. The issue arises because custom errors are only available using the via-IR pipeline. To resolve this, we refactor the code to use an if statement with a revert for the custom error.

Changes Made:

  • Refactored the require statement to use an if statement with revert.

Before:

require(amount <= balances[msg.sender], InsufficientBalance(amount, balances[msg.sender]));

After:

if (amount > balances[msg.sender]) {
    revert InsufficientBalance(amount, balances[msg.sender]);
}

Please review the changes and let me know if there are any questions or further adjustments needed.

Copy link

github-actions bot commented Jul 6, 2024

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.

@nikola-matic
Copy link
Collaborator

Hi @tal7aouy, I'll be closing this since it's a bit of a moot point, since require(bool, Error()) will be available in the default pipeline in the next release anyway.

I did however notice that I actually missed this exact page when updating the docs for said feature - so if you're up for it, feel free to open another PR when you would need to bump the version pragma to 0.8.27, and to get rid of this comment.

@tal7aouy
Copy link
Author

Hi @nikola-matic Thank you . ofcourse i will :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants