Skip to content

Commit

Permalink
Fix modified namespaced compilation when multiple return parameters a…
Browse files Browse the repository at this point in the history
…re documented (#1048)
  • Loading branch information
ericglau authored Jul 19, 2024
1 parent 88e2c1b commit 6a9aef6
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.34.3 (2024-07-19)

- Fix Hardhat compile error when multiple return parameters are documented. ([#1048](https://github.com/OpenZeppelin/openzeppelin-upgrades/pull/1048))

## 1.34.2 (2024-07-18)

- Fix Hardhat compile error when constants have references to other constants. ([#1046](https://github.com/OpenZeppelin/openzeppelin-upgrades/pull/1046))
Expand Down
33 changes: 32 additions & 1 deletion packages/core/contracts/test/NamespacedToModify.sol
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,35 @@ contract HasFunctionWithRequiredReturn {
function foo(S calldata s) internal pure returns (S calldata) {
return s;
}
}
}

/**
* @return uint 1
* @return uint 2
*/
function hasMultipleReturns() pure returns (uint, uint) {
return (1, 2);
}

/**
* @return a first
* @return b second
*/
function hasMultipleNamedReturns() pure returns (uint a, uint b) {
}

contract HasNatSpecWithMultipleReturns {
/**
* @return uint 1
* @return uint 2
*/
function hasMultipleReturnsInContract() public pure returns (uint, uint) {
}

/**
* @return a first
* @return b second
*/
function hasMultipleNamedReturnsInContract() public pure returns (uint a, uint b) {
}
}
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openzeppelin/upgrades-core",
"version": "1.34.2",
"version": "1.34.3",
"description": "",
"repository": "https://github.com/OpenZeppelin/openzeppelin-upgrades/tree/master/packages/core",
"license": "MIT",
Expand Down
29 changes: 28 additions & 1 deletion packages/core/src/utils/make-namespaced.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,34 @@ Generated by [AVA](https://avajs.dev).
contract HasFunctionWithRequiredReturn {␊
struct S { uint x; }␊
function foo(S calldata s) internal pure returns (bool) {}␊
}`,
}␊
/**␊
* @return uint 1␊
* @return uint 2␊
*/␊
function hasMultipleReturns() pure returns (bool,bool) {}␊
/**␊
* @return a first␊
* @return b second␊
*/␊
function hasMultipleNamedReturns() pure returns (bool,bool) {}␊
contract HasNatSpecWithMultipleReturns {␊
/**␊
* @return uint 1␊
* @return uint 2␊
*/␊
function hasMultipleReturnsInContract() public pure returns (bool,bool) {}␊
/**␊
* @return a first␊
* @return b second␊
*/␊
function hasMultipleNamedReturnsInContract() public pure returns (bool,bool) {}␊
}␊
`,
},
'contracts/test/NamespacedToModifyImported.sol': {
content: `// SPDX-License-Identifier: MIT␊
Expand Down
Binary file modified packages/core/src/utils/make-namespaced.test.ts.snap
Binary file not shown.
4 changes: 3 additions & 1 deletion packages/core/src/utils/make-namespaced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ function replaceFunction(node: FunctionDefinition, orig: Buffer, modifications:
}

if (node.returnParameters.parameters.length > 0) {
modifications.push(makeReplace(node.returnParameters, orig, '(bool)'));
modifications.push(
makeReplace(node.returnParameters, orig, `(${node.returnParameters.parameters.map(() => 'bool').join(',')})`),
);
}

if (node.body) {
Expand Down

0 comments on commit 6a9aef6

Please sign in to comment.