百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
返回工具页/返回 Issues 列表
#16596·solidity

`ConstantEvaluator` 不会截断左移运算的结果

作者: matheusaaguiar创建于 2026年4月15日更新于 2026年9月29日
标签bug :bug:

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

查看 GitHub 原文在 GitHub 查看讨论