+
Skip to content

Conversation

sashass1315
Copy link

Previously, the unroll_for_loops attribute accepted 0 as a valid integer because syn parses it as Lit::Int and we converted it to usize without additional checks. While negatives were already impossible (they parse as a unary minus over an int and are rejected), zero slipped through. This led to generated code in unroll.rs performing division and modulo by the unroll factor, causing a guaranteed runtime panic when unroll_by == 0.
This change adds an explicit guard in ff-macros/src/lib.rs to reject unroll_by == 0 with the same ARG_MSG (“must be a positive integer”), enforcing the documented constraint and converting a runtime panic into a compile-time error. No API changes; existing valid usages (e.g., 6, 12) are unaffected.

@sashass1315 sashass1315 requested review from a team as code owners September 24, 2025 12:36
@sashass1315 sashass1315 requested review from mmagician, weikengchen and z-tech and removed request for a team September 24, 2025 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载