Skip to content

Commit d43766a

Browse files
authored
Skip Slang parser for solc versions that it does not support (#1075)
1 parent 034feb9 commit d43766a

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
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.37.1 (2024-09-09)
4+
5+
- Fix Hardhat compile error when using solc version `0.8.27`. ([#1075](https://github.com/OpenZeppelin/openzeppelin-upgrades/pull/1075))
6+
37
## 1.37.0 (2024-08-28)
48

59
- **Breaking change**: CLI: Disallow self-references for storage layout validations. ([#1067](https://github.com/OpenZeppelin/openzeppelin-upgrades/pull/1067))

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.37.0",
3+
"version": "1.37.1",
44
"description": "",
55
"repository": "https://github.com/OpenZeppelin/openzeppelin-upgrades/tree/master/packages/core",
66
"license": "MIT",

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,15 @@ export function makeNamespacedInput(input: SolcInput, output: SolcOutput, solcVe
164164
}
165165

166166
/**
167-
* If Slang is supported for the current platform and we have the compiler version available,
167+
* If we have the compiler version available and Slang is supported for the current platform and compiler version,
168168
* use Slang to parse and remove all NatSpec comments that do not precede a struct definition and return the modified content.
169169
*
170170
* Otherwise, return the original content.
171171
*/
172172
function tryRemoveNonStructNatSpec(origContent: string, solcVersion: string | undefined): string {
173173
const natSpecRemovals: Modification[] = [];
174174

175-
if (solcVersion !== undefined && tryRequire('@nomicfoundation/slang')) {
175+
if (solcVersion !== undefined && tryRequire('@nomicfoundation/slang') && slangSupportsVersion(solcVersion)) {
176176
/* eslint-disable @typescript-eslint/no-var-requires */
177177
const { Language } = require('@nomicfoundation/slang/language');
178178
const { NonterminalKind, TerminalKind } = require('@nomicfoundation/slang/kinds');
@@ -217,6 +217,14 @@ function tryRequire(id: string) {
217217
return false;
218218
}
219219

220+
function slangSupportsVersion(solcVersion: string): boolean {
221+
/* eslint-disable @typescript-eslint/no-var-requires */
222+
const { Language } = require('@nomicfoundation/slang/language');
223+
/* eslint-enable @typescript-eslint/no-var-requires */
224+
225+
return Language.supportedVersions().includes(solcVersion);
226+
}
227+
220228
interface Modification {
221229
start: number;
222230
end: number;

0 commit comments

Comments
 (0)