Skip to content

Commit 0f978ea

Browse files
committed
Fix named error paremeter encoding order in IR codegen
1 parent 7b85eba commit 0f978ea

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Compiler Features:
1212
* Yul EVM Code Transform: Improve stack shuffler performance by fixing a BFS deduplication issue.
1313

1414
Bugfixes:
15+
* Yul IR Code Generation: Encode custom error named parameters in declaration order instead of call-site order.
1516

1617

1718
### 0.8.34 (2026-02-18)

libsolidity/codegen/ir/IRGeneratorForStatements.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall)
11681168
{
11691169
auto const& errorConstructorCall = dynamic_cast<FunctionCall const&>(*arguments[1]);
11701170
appendCode() << m_utils.requireWithErrorFunction(errorConstructorCall) << "(" <<IRVariable(*arguments[0]).name();
1171-
for (auto argument: errorConstructorCall.arguments())
1171+
for (auto argument: errorConstructorCall.sortedArguments())
11721172
if (argument->annotation().type->sizeOnStack() > 0)
11731173
appendCode() << ", " << IRVariable(*argument).commaSeparatedList();
11741174
appendCode() << ")\n";
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
error NamedArgsError2(uint256 a, uint256 b);
2+
error NamedArgsError3(uint256 a, uint256 b, uint256 c);
3+
error NamedArgsError4(uint256 a, string b, uint256 c, bool d);
4+
5+
contract C {
6+
function trigger1() external pure {
7+
require(false, NamedArgsError2({a: 2, b: 7}));
8+
}
9+
function trigger2() external pure {
10+
require(false, NamedArgsError2({b: 7, a: 2}));
11+
}
12+
function trigger3() external pure {
13+
require(false, NamedArgsError3({c: 9, a: 2, b: 7}));
14+
}
15+
function trigger4() external pure {
16+
require(false, NamedArgsError4({b: "error", a: 2, c: 9, d: true}));
17+
}
18+
}
19+
20+
// ----
21+
// trigger1() -> FAILURE, hex"59f176a3", 2, 7
22+
// trigger2() -> FAILURE, hex"59f176a3", 2, 7
23+
// trigger3() -> FAILURE, hex"b912b8d4", 2, 7, hex"0000000000000000000000000000000000000000000000000000000000000009"
24+
// trigger4() -> FAILURE, hex"8ae9981b", 2, hex"0000000000000000000000000000000000000000000000000000000000000080", 9, true, 5, hex"6572726f72000000000000000000000000000000000000000000000000000000"

0 commit comments

Comments
 (0)