Scribbles grammar generates invalid FixedBytes type objects
cd1m0 opened this issue · 0 comments
cd1m0 commented
Given the following code:
pragma solidity 0.8.12;
contract Foo {
/// #if_succeeds forall(bytes32 x in hashes) x != bytes32(0x0);
function foo(bytes32[] memory hashes) public {}
}
Scribble outputs the following error:
tmp.sol:4:36 TypeError: The type bytes[object Object] of the iterator variable x is not compatible with iterator type uint of hashes.
tmp.sol:4:36:
/// #if_succeeds forall(bytes32 x in hashes) x != bytes32(0x0);
Note the [object Object]
part of the string. This comes from the FixedBytesType
pretty printer, and indicates that the number field of the FixedBytesType
is invalid. The issue is on line 702 of the scribble grammar:
FixedSizeBytesType =
BYTES width: Number {
return new FixedBytesType(width, makeRange(location(), options as ParseOptions));
}
/ BYTE {
return new FixedBytesType(1, makeRange(location(), options as ParseOptions));
}
Specifically the width: Number
grammar member returns an SNumber
object, while the FixedBytesType
constructor expects a simple JS number.