diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 9cf37dfe2..374713036 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.33.1 (2024-04-25) + +- Fix Hardhat compile error when variable has whitespace before semicolon. ([#1020](https://github.com/OpenZeppelin/openzeppelin-upgrades/pull/1020)) + ## 1.33.0 (2024-04-24) - Enable changing default network files directory with environment variable. ([#1011](https://github.com/OpenZeppelin/openzeppelin-upgrades/pull/1011)) diff --git a/packages/core/contracts/test/NamespacedToModify.sol b/packages/core/contracts/test/NamespacedToModify.sol index d1d43977f..7175a6166 100644 --- a/packages/core/contracts/test/NamespacedToModify.sol +++ b/packages/core/contracts/test/NamespacedToModify.sol @@ -66,6 +66,13 @@ contract Example { * @dev a custom error inside a contract */ error CustomErrorInsideContract(address a); + + uint256 public spaceSemicolon ; + uint256 public twoSpacesSemicolon ; + uint256 public tabSemicolon ; + uint256 public lineBreakSemicolon + ; + error SpaceSemicolon(uint256 a) ; } contract HasFunction { diff --git a/packages/core/package.json b/packages/core/package.json index 4f7f94f08..414b47c00 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@openzeppelin/upgrades-core", - "version": "1.33.0", + "version": "1.33.1", "description": "", "repository": "https://github.com/OpenZeppelin/openzeppelin-upgrades/tree/master/packages/core", "license": "MIT", diff --git a/packages/core/src/utils/make-namespaced.test.ts.md b/packages/core/src/utils/make-namespaced.test.ts.md index d134cb685..98e13bb75 100644 --- a/packages/core/src/utils/make-namespaced.test.ts.md +++ b/packages/core/src/utils/make-namespaced.test.ts.md @@ -90,6 +90,12 @@ Generated by [AVA](https://avajs.dev). * @dev a custom error inside a contract␊ */␊ enum $astId_id_random { dummy }␊ + ␊ + enum $astId_id_random { dummy }␊ + enum $astId_id_random { dummy }␊ + enum $astId_id_random { dummy }␊ + enum $astId_id_random { dummy }␊ + enum $astId_id_random { dummy }␊ }␊ ␊ contract HasFunction {␊ diff --git a/packages/core/src/utils/make-namespaced.test.ts.snap b/packages/core/src/utils/make-namespaced.test.ts.snap index 9877bb71b..3ce108427 100644 Binary files a/packages/core/src/utils/make-namespaced.test.ts.snap and b/packages/core/src/utils/make-namespaced.test.ts.snap differ diff --git a/packages/core/src/utils/make-namespaced.ts b/packages/core/src/utils/make-namespaced.ts index 9cf5c334f..bdf2a9aa6 100644 --- a/packages/core/src/utils/make-namespaced.ts +++ b/packages/core/src/utils/make-namespaced.ts @@ -178,9 +178,14 @@ function makeInsertAfter(node: Node, text: string): Modification { function makeDelete(node: Node, orig: Buffer): Modification { const positions = getPositions(node); let end = positions.end; - // If the next character is a semicolon for variables, skip over it - if (isNodeType('VariableDeclaration', node) && end + 1 < orig.length && orig.toString('utf8', end, end + 1) === ';') { - end += 1; + // For variables, skip past whitespaces and the first semicolon + if (isNodeType('VariableDeclaration', node)) { + while (end + 1 < orig.length && orig.toString('utf8', end, end + 1).trim() === '') { + end += 1; + } + if (end + 1 < orig.length && orig.toString('utf8', end, end + 1) === ';') { + end += 1; + } } return { start: positions.start, end }; }