Skip to content

Do not remove custom errors in IR codegen when strip revert strings is requested#16466

Merged
matheusaaguiar merged 3 commits intodevelopfrom
fixRevertStringFlagInconsistentHandling
Apr 29, 2026
Merged

Do not remove custom errors in IR codegen when strip revert strings is requested#16466
matheusaaguiar merged 3 commits intodevelopfrom
fixRevertStringFlagInconsistentHandling

Conversation

@matheusaaguiar
Copy link
Copy Markdown
Contributor

Fix #16465.

@argotorg argotorg deleted a comment from stackenbotten3000 Feb 11, 2026
@matheusaaguiar matheusaaguiar changed the title Make legacy codege remove custom errors when compiler option revert-strings strip is requested Make legacy codegen remove custom errors when compiler option revert-strings strip is requested Feb 11, 2026
@matheusaaguiar matheusaaguiar changed the title Make legacy codegen remove custom errors when compiler option revert-strings strip is requested Make legacy codegen remove custom errors when compiler option revert-strings=strip is requested Feb 11, 2026
@cameel
Copy link
Copy Markdown
Collaborator

cameel commented Feb 11, 2026

We need to also adjust documentation as a part of this issue.

And consider changing the option or value names to make it more intuitive.

Copy link
Copy Markdown
Contributor

@nikola-matic nikola-matic left a comment

Choose a reason for hiding this comment

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

The asm output test is definitely necessary, but please add more semantic test coverage; there's the // revertStrings: strip option for this.

Comment thread test/cmdlineTests/revert_strings_strip_legacy/input.sol Outdated
Comment thread test/cmdlineTests/revert_strings_strip_legacy/input.sol Outdated
Comment thread libsolidity/codegen/ExpressionCompiler.cpp Outdated
@matheusaaguiar matheusaaguiar force-pushed the fixRevertStringFlagInconsistentHandling branch 3 times, most recently from 4913b7d to 8450ab7 Compare February 26, 2026 05:43
@matheusaaguiar matheusaaguiar changed the title Make legacy codegen remove custom errors when compiler option revert-strings=strip is requested Do not remove custom errors in IR codegen when strip revert strings is requested Feb 26, 2026
@cameel cameel requested a review from rodiazet March 16, 2026 13:25
@matheusaaguiar matheusaaguiar force-pushed the fixRevertStringFlagInconsistentHandling branch 3 times, most recently from f3491de to 1de843a Compare March 17, 2026 01:38
Copy link
Copy Markdown
Contributor

@rodiazet rodiazet left a comment

Choose a reason for hiding this comment

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

LGTM in general. I found a couple of small issues mainly with test coverage. There is also one question I have regarding the way how the old version worked.

Comment thread libsolidity/codegen/ir/IRGeneratorForStatements.cpp
Comment thread libsolidity/codegen/ir/IRGeneratorForStatements.cpp Outdated
Comment thread Changelog.md Outdated
Comment thread libsolidity/codegen/ir/IRGeneratorForStatements.cpp
{
auto const& errorConstructorCall = dynamic_cast<FunctionCall const&>(*arguments[1]);
appendCode() << m_utils.requireWithErrorFunction(errorConstructorCall) << "(" <<IRVariable(*arguments[0]).name();
for (auto argument: errorConstructorCall.arguments())
Copy link
Copy Markdown
Contributor

@rodiazet rodiazet Mar 17, 2026

Choose a reason for hiding this comment

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

Does it make sense to add test case where there is zero custom error arguments to make sure that this corner case (zero for loop iterations) also works properly?
error MyError(); require(false, MyError()) and probably error MyError(); require(true, MyError())

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added.

Comment thread libsolidity/codegen/ir/IRGeneratorForStatements.cpp
@matheusaaguiar matheusaaguiar force-pushed the fixRevertStringFlagInconsistentHandling branch from 1de843a to f761ded Compare March 18, 2026 05:02
Comment thread libsolidity/codegen/ir/IRGeneratorForStatements.cpp Outdated
@matheusaaguiar
Copy link
Copy Markdown
Contributor Author

I think I addressed all corrections and suggestions.
I added a brief explanation of the behavior of the option in the existing documented example in the Standard JSON Input Output section. I have started a separated PR to refine that and have the options and their explanation better organized.

clonker
clonker previously approved these changes Apr 13, 2026
Copy link
Copy Markdown
Member

@clonker clonker left a comment

Choose a reason for hiding this comment

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

It looks good to me and as far as I can tell, all reviewer comments have been addressed. Two tiny suggestions, feel free to ignore. I guess @nikola-matic and/or @rodiazet might want to check that for their own comments, too. Not sure if @cameel wants to have a look before this goes in.

Comment thread docs/using-the-compiler.rst Outdated
Comment thread libsolidity/codegen/ir/IRGeneratorForStatements.cpp Outdated
@cameel
Copy link
Copy Markdown
Collaborator

cameel commented Apr 13, 2026

Not sure if @cameel wants to have a look before this goes in.

Yes, I was planning to take a look.

@matheusaaguiar matheusaaguiar force-pushed the fixRevertStringFlagInconsistentHandling branch from 8815e6f to bd6acbd Compare April 13, 2026 16:28
@matheusaaguiar matheusaaguiar force-pushed the fixRevertStringFlagInconsistentHandling branch from bd6acbd to 5fc923f Compare April 23, 2026 17:29
Copy link
Copy Markdown
Collaborator

@cameel cameel left a comment

Choose a reason for hiding this comment

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

The docs need a correction - we were not always removing the custom errors. Just in require().

Other than that there are a few minor things that could be cleaned up, but no real blockers.

Comment thread Changelog.md Outdated
Comment thread docs/using-the-compiler.rst Outdated
Comment thread docs/using-the-compiler.rst
@matheusaaguiar matheusaaguiar force-pushed the fixRevertStringFlagInconsistentHandling branch 2 times, most recently from 7d54e84 to bf021b3 Compare April 28, 2026 03:12
Comment thread solc/CommandLineParser.cpp Outdated
@matheusaaguiar matheusaaguiar force-pushed the fixRevertStringFlagInconsistentHandling branch from 2c60489 to 03486ef Compare April 28, 2026 21:25
@cameel cameel dismissed rodiazet’s stale review April 28, 2026 23:24

Comments were addressed.

@matheusaaguiar matheusaaguiar merged commit 9b58abf into develop Apr 29, 2026
83 checks passed
@matheusaaguiar matheusaaguiar deleted the fixRevertStringFlagInconsistentHandling branch April 29, 2026 00: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.

Compiler option revert-strings with value strip has different treatments in legacy and IR pipeline

5 participants