8000 refactor: remove loop vars that are not updated by Yu-zh · Pull Request #2358 · moonbitlang/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

refactor: remove loop vars that are not updated #2358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2025

Conversation

Yu-zh
Copy link
Collaborator
@Yu-zh Yu-zh commented Jun 26, 2025

No description provided.

@coveralls
Copy link
Collaborator
coveralls commented Jun 26, 2025

Pull Request Test Coverage Report for Build 78

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 89.003%

Totals Coverage Status
Change from base Build 77: 0.0%
Covered Lines: 3464
Relevant Lines: 3892

💛 - Coveralls

@Yu-zh Yu-zh force-pushed the cleanup-loop-vars branch from c6584e7 to b9b2201 Compare June 26, 2025 10:07
Copy link
peter-jerry-ye-code-review bot commented Jun 26, 2025
Consistent improvement in loop syntax across files

Category
Maintainability
Code Snippet
Changed from:
for i = 0, len = arr.length(); i < len; i = i + 1
to:
for i in 0..<arr.length()
Recommendation
The changes are good. Consider updating any remaining C-style loops in the codebase for consistency.
Reasoning
The new range-based syntax is more concise, more readable, and less error-prone as it eliminates the need for manual increment and bound checking.

Range operator usage needs validation

Category
Correctness
Code Snippet
0..<arr.length()
Recommendation
Verify that the half-open range operator (..<) is inclusive of the start and exclusive of the end value as intended.
Reasoning
When changing loop constructs, it's critical to ensure the iteration bounds remain exactly the same. The half-open range should iterate up to but not including arr.length().

Documentation update needed

Category
Maintainability
Code Snippet
Multiple files including fixedarray_sort.mbt, iter_test.mbt, and bytes.mbt
Recommendation
Add comments or update existing documentation to reflect the new loop syntax where relevant.
Reasoning
Documentation should be updated to match the actual code syntax, especially in example code sections, to avoid confusion for new developers.

@bobzhang bobzhang force-pushed the cleanup-loop-vars branch from b9b2201 to 14abdca Compare June 26, 2025 23:23
@bobzhang bobzhang enabled auto-merge (rebase) June 26, 2025 23:26
@bobzhang bobzhang merged commit 540fb9c into moonbitlang:main Jun 26, 2025
10 checks passed
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.

3 participants
0