From cd0e4c7af2c028e91a32ad3fb7a2ac173cf77f2b Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Thu, 29 Aug 2024 16:44:44 -0300 Subject: [PATCH] Fix InlineAssembly schema errors (#50) --- CHANGELOG.md | 5 +++++ package-lock.json | 4 ++-- package.json | 2 +- scripts/build-schema.js | 6 +++--- test/sources/asm-0.6.sol | 4 ++++ test/sources/asm-0.7.5.sol | 9 +++++++++ test/sources/asm-0.7.sol | 4 ++++ 7 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 test/sources/asm-0.7.5.sol diff --git a/CHANGELOG.md b/CHANGELOG.md index 87a33b9..c412c36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +### 0.4.58 (2024-08-29) + +- Fixed `YulFunctionDefinition.parameters` and `returnVariables`: made optional, used when empty. +- Fixed `InlineAssembly.externalReferences[].suffix`: added `'length'` option. + ### 0.4.57 (2024-07-16) - Fixed `ModifierDefinition.body`: made nullable to support Solidity 0.6.7 virtual modifiers with empty body. diff --git a/package-lock.json b/package-lock.json index eb56023..618946b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "solidity-ast", - "version": "0.4.57", + "version": "0.4.58", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "solidity-ast", - "version": "0.4.57", + "version": "0.4.58", "license": "MIT", "devDependencies": { "@types/lodash": "^4.17.7", diff --git a/package.json b/package.json index c27cbda..b71cd83 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "solidity-ast", - "version": "0.4.57", + "version": "0.4.58", "description": "Solidity AST schema and type definitions", "author": "Francisco Giordano ", "repository": "github:OpenZeppelin/solidity-ast", diff --git a/scripts/build-schema.js b/scripts/build-schema.js index a454408..b1d37ca 100644 --- a/scripts/build-schema.js +++ b/scripts/build-schema.js @@ -498,7 +498,7 @@ const schema = { isSlot: boolean, src: ref('SourceLocation'), valueSize: integer, - suffix: optional(literal('slot', 'offset')), + suffix: optional(literal('slot', 'offset', 'length')), })), flags: optional(array(literal('memory-safe'))), }, @@ -817,8 +817,8 @@ const schema = { YulFunctionDefinition: { body: ref('YulBlock'), name: string, - parameters: array(ref('YulTypedName')), - returnVariables: array(ref('YulTypedName')), + parameters: optional(array(ref('YulTypedName'))), + returnVariables: optional(array(ref('YulTypedName'))), }, YulIdentifier: { diff --git a/test/sources/asm-0.6.sol b/test/sources/asm-0.6.sol index b4bfce6..b01a197 100644 --- a/test/sources/asm-0.6.sol +++ b/test/sources/asm-0.6.sol @@ -7,6 +7,10 @@ contract Asm { assembly { let x := s_slot let y := s_offset + + function fail() { + revert(0, 0) + } } } } diff --git a/test/sources/asm-0.7.5.sol b/test/sources/asm-0.7.5.sol new file mode 100644 index 0000000..896b974 --- /dev/null +++ b/test/sources/asm-0.7.5.sol @@ -0,0 +1,9 @@ +pragma solidity >=0.7.5; + +contract Asm { + function foo(bytes calldata b) external { + assembly { + let z := b.length + } + } +} diff --git a/test/sources/asm-0.7.sol b/test/sources/asm-0.7.sol index ebb3c43..b41c697 100644 --- a/test/sources/asm-0.7.sol +++ b/test/sources/asm-0.7.sol @@ -7,6 +7,10 @@ contract Asm { assembly { let x := s.slot let y := s.offset + + function fail() { + revert(0, 0) + } } } }