Skip to content

Commit 6a9aef6

Browse files
authored
Fix modified namespaced compilation when multiple return parameters are documented (#1048)
1 parent 88e2c1b commit 6a9aef6

File tree

6 files changed

+68
-4
lines changed

6 files changed

+68
-4
lines changed

packages/core/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.34.3 (2024-07-19)
4+
5+
- Fix Hardhat compile error when multiple return parameters are documented. ([#1048](https://github.com/OpenZeppelin/openzeppelin-upgrades/pull/1048))
6+
37
## 1.34.2 (2024-07-18)
48

59
- Fix Hardhat compile error when constants have references to other constants. ([#1046](https://github.com/OpenZeppelin/openzeppelin-upgrades/pull/1046))

packages/core/contracts/test/NamespacedToModify.sol

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,35 @@ contract HasFunctionWithRequiredReturn {
214214
function foo(S calldata s) internal pure returns (S calldata) {
215215
return s;
216216
}
217-
}
217+
}
218+
219+
/**
220+
* @return uint 1
221+
* @return uint 2
222+
*/
223+
function hasMultipleReturns() pure returns (uint, uint) {
224+
return (1, 2);
225+
}
226+
227+
/**
228+
* @return a first
229+
* @return b second
230+
*/
231+
function hasMultipleNamedReturns() pure returns (uint a, uint b) {
232+
}
233+
234+
contract HasNatSpecWithMultipleReturns {
235+
/**
236+
* @return uint 1
237+
* @return uint 2
238+
*/
239+
function hasMultipleReturnsInContract() public pure returns (uint, uint) {
240+
}
241+
242+
/**
243+
* @return a first
244+
* @return b second
245+
*/
246+
function hasMultipleNamedReturnsInContract() public pure returns (uint a, uint b) {
247+
}
248+
}

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openzeppelin/upgrades-core",
3-
"version": "1.34.2",
3+
"version": "1.34.3",
44
"description": "",
55
"repository": "https://github.com/OpenZeppelin/openzeppelin-upgrades/tree/master/packages/core",
66
"license": "MIT",

packages/core/src/utils/make-namespaced.test.ts.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,34 @@ Generated by [AVA](https://avajs.dev).
215215
contract HasFunctionWithRequiredReturn {␊
216216
struct S { uint x; }␊
217217
function foo(S calldata s) internal pure returns (bool) {}␊
218-
}`,
218+
}␊
219+
220+
/**␊
221+
* @return uint 1␊
222+
* @return uint 2␊
223+
*/␊
224+
function hasMultipleReturns() pure returns (bool,bool) {}␊
225+
226+
/**␊
227+
* @return a first␊
228+
* @return b second␊
229+
*/␊
230+
function hasMultipleNamedReturns() pure returns (bool,bool) {}␊
231+
232+
contract HasNatSpecWithMultipleReturns {␊
233+
/**␊
234+
* @return uint 1␊
235+
* @return uint 2␊
236+
*/␊
237+
function hasMultipleReturnsInContract() public pure returns (bool,bool) {}␊
238+
239+
/**␊
240+
* @return a first␊
241+
* @return b second␊
242+
*/␊
243+
function hasMultipleNamedReturnsInContract() public pure returns (bool,bool) {}␊
244+
}␊
245+
`,
219246
},
220247
'contracts/test/NamespacedToModifyImported.sol': {
221248
content: `// SPDX-License-Identifier: MIT␊
110 Bytes
Binary file not shown.

packages/core/src/utils/make-namespaced.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ function replaceFunction(node: FunctionDefinition, orig: Buffer, modifications:
175175
}
176176

177177
if (node.returnParameters.parameters.length > 0) {
178-
modifications.push(makeReplace(node.returnParameters, orig, '(bool)'));
178+
modifications.push(
179+
makeReplace(node.returnParameters, orig, `(${node.returnParameters.parameters.map(() => 'bool').join(',')})`),
180+
);
179181
}
180182

181183
if (node.body) {

0 commit comments

Comments
 (0)