solidity icon indicating copy to clipboard operation
solidity copied to clipboard

`bytes.concat` is not allowed in constant initializers

Open ItsNickBarry opened this issue 10 months ago • 2 comments

Description

bytes.concat does not work when defining constants.

Environment

  • Compiler version: 0.8.21
  • Target EVM version (as per compiler settings): Hardhat default
  • Framework/IDE (e.g. Truffle or Remix): Hardhat
  • EVM execution environment / backend / blockchain client: N/A
  • Operating system: Ubuntu

Steps to Reproduce

This code compiles:

contract Test {
    bytes32 internal constant A = bytes32('a');
    bytes32 internal constant B = bytes32('b');
    bytes internal constant AB = abi.encodePacked(A, B);
}

This does not:

contract Test {
    bytes32 internal constant A = bytes32('a');
    bytes32 internal constant B = bytes32('b');
    bytes internal constant AB = bytes.concat(A, B);
}

ItsNickBarry avatar Aug 21 '23 21:08 ItsNickBarry