# Solidity0.8.22 版本更新 **Published by:** [马赫斯.7](https://paragraph.com/@0xmaahes/) **Published on:** 2023-10-31 **URL:** https://paragraph.com/@0xmaahes/solidity0-8-22 ## Content 更新速览 unchecked循环 Yul优化器调整,以重新生成零字面量 导入 EVM 汇编 JSON 的支持(实验性) 文件级别定义事件 unchecked循环 在0.8.22版本的更新中,我注意到有一个备受争议的更新,即在循环场景下不再进行溢出检查。 接下来,我们将详细讨论一下这个循环不检查溢出的设计机制。 为什么要这么设计 减少循环溢出检查所消耗的gas 大部分循环场景都在一定范围内进行条件判断,可以有效避免溢出的可能性 代码更易读 不检查溢出的满足条件 满足unchecked循环的条件如下: 比较运算符:循环条件是形如 i < ... 的比较, 不能是<=或者其他的比较运算符。 隐式转换:i<...比较运算中,右侧类型必须可以隐式的转换成循环计数器i的类型 // 不能转换,所以必须检查溢出 for (uint8 i = 0; i < uint16(1000); ++i) { } 内置整型类型:i<...,i必须是内置的整型类型 递增:i++或++i 不能修改:i<...,i不能再循环条件或循环体中修改 如何禁止这个优化 在标准JSON输入中,将settings.optimizer.details.simpleCounterForLoopUncheckedIncrement设置为false,以关闭这个优化。 扩展阅读 Release Version 0.8.22 · ethereum/solidity · GitHub Subscribe ## Publication Information - [马赫斯.7](https://paragraph.com/@0xmaahes/): Publication homepage - [All Posts](https://paragraph.com/@0xmaahes/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@0xmaahes): Subscribe to updates