Skip to content

Fix named error parameter encoding order in IR codegen#16453

Open
nikola-matic wants to merge 1 commit intodevelopfrom
fix-named-error-paramater-encoding-in-ir
Open

Fix named error parameter encoding order in IR codegen#16453
nikola-matic wants to merge 1 commit intodevelopfrom
fix-named-error-paramater-encoding-in-ir

Conversation

@nikola-matic
Copy link
Contributor

Closes #16452

auto const& errorConstructorCall = dynamic_cast<FunctionCall const&>(*arguments[1]);
appendCode() << m_utils.requireWithErrorFunction(errorConstructorCall) << "(" <<IRVariable(*arguments[0]).name();
for (auto argument: errorConstructorCall.arguments())
for (auto argument: errorConstructorCall.sortedArguments())
Copy link
Collaborator

@cameel cameel Feb 9, 2026

Choose a reason for hiding this comment

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

Dealing with named arguments is actually quite error prone. This is not the first time we have a bug of this kind (#9766). While the change here may be enough for the fix, I think we should also take some steps to prevent this happening yet again (could be a separate PR on top of the fix).

We have this FuncCallArguments struct. I think we should get rid of the arguments()/sortedArguments() pair and instead always pass around arguments in this container. Then make it iterable and only in the right, sorted order. We can keep a special method for accessing them in the call order for corner cases in which you actually do want that.

@cameel cameel changed the title Fix named error paremeter encoding order in IR codegen Fix named error parameter encoding order in IR codegen Feb 9, 2026
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.

Custom error named parameters passed in call order instead of declaration order

2 participants

Comments