`ConstantEvaluator` 不会截断左移运算的结果
The ConstantEvaluator does not truncate the result of shift and bit not operations, resulting in errors when the raw value is out of range of the target type or when it exceeds the hard cap of 4096-bit precision. This happens, for example, when evaluating array lengths or storage layout specifiers. The behavior is inconsistent with codegen, where the value is cleaned up either lazily (evmasm) or at the end of the operation (IR) to fit the type width. The documentation section on shifts describes the correct process, stating that the result of a shift operation has the type of the left operand, overflow checks are never performed, and the value is always truncated. Also when the left operand is a literal and the right operand is an integer, shifts are always performed in the uint256 or int256 type. This problem affects left shift and bit not operations. Right shifts are not impacted because the result is always smaller than or equal to the left operand. Minimal repro:
内容来源: argotorg/solidity