Open
Description
Description
An immutable variable that is initialized at declaration site can be used in pure
context if it is of type uint
but not if it is of type address
.
Environment
- Compiler version: 0.8.29
Steps to Reproduce
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.29;
contract Test {
address internal immutable _a = 0x0000000000000000000000000000000000000001;
uint256 internal immutable _b = 42;
function a() external pure returns (address) {
return _a; // TypeError: Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
}
function b() external pure returns (uint256) {
return _b; // no error
}
}