-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Open
Labels
bug 🐛low effortThere is not much implementation work to be done. The task is very easy or tiny.There is not much implementation work to be done. The task is very easy or tiny.low impactChanges are not very noticeable or potential benefits are limited.Changes are not very noticeable or potential benefits are limited.must have eventuallySomething we consider essential but not enough to prevent us from releasing Solidity 1.0 without it.Something we consider essential but not enough to prevent us from releasing Solidity 1.0 without it.
Description
Description
When defining a constant
variable of type bytes
and initializing with some bytes that are concatenated together:
- the method
abi.encodePacked(...)
works ✅ - but not the method
bytes.concat(...)
❌
Environment
- Compiler version: 0.8.30
- Compilation pipeline (legacy, IR, EOF): none
- Target EVM version (as per compiler settings): cancun
- Framework/IDE (e.g. Foundry, Hardhat, Remix): Foundry
Steps to Reproduce
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.30;
contract Example {
// ✅ Compile successfully
bytes public constant A = abi.encodePacked(
hex"aaaa",
hex"bbbb",
hex"cccc"
);
// ❌ TypeError: Initial value for constant variable has to be compile-time constant.
bytes public constant B = bytes.concat(
hex"aaaa",
hex"bbbb",
hex"cccc"
);
}
Metadata
Metadata
Assignees
Labels
bug 🐛low effortThere is not much implementation work to be done. The task is very easy or tiny.There is not much implementation work to be done. The task is very easy or tiny.low impactChanges are not very noticeable or potential benefits are limited.Changes are not very noticeable or potential benefits are limited.must have eventuallySomething we consider essential but not enough to prevent us from releasing Solidity 1.0 without it.Something we consider essential but not enough to prevent us from releasing Solidity 1.0 without it.