8000 hongbo/get rid of warnings by bobzhang · Pull Request #2277 · moonbitlang/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

hongbo/get rid of warnings #2277

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 2 commits into from
Jun 15, 2025
Merged

hongbo/get rid of warnings #2277

merged 2 commits into from
Jun 15, 2025

Conversation

bobzhang
Copy link
Contributor
  • deprecate _.rev_fold and _rev.foldi
  • get rid of warnings

Copy link
Good deprecation practice with clear migration path

Category
Maintainability
Code Snippet
#deprecated("use _.rev().fold(...) instead")
pub fn[A, B] T::rev_fold(self : T[A], init~ : B, f : (B, A) -> B) -> B
Recommendation
The current approach is correct. Keep as is.
Reasoning
The deprecation notice clearly indicates the alternative approach, making it easy for users to migrate their code. This follows good API evolution practices.

Consider optimizing rev_foldi implementation

Category
Performance
Code Snippet
pub fn[A, B] T::rev_foldi(self : T[A], init~ : B, f : (Int, B, A) -> B) -> B {
self.rev().foldi(init~, fn(i, b, a) { f(i, b, a) })
}
Recommendation
Since the function is deprecated, the current implementation is acceptable. However, if it wasn't being deprecated, it could be optimized to avoid the intermediate list creation from rev()
Reasoning
The current implementation creates an intermediate reversed list before folding, which has O(n) space complexity. A direct implementation could avoid this overhead.

Test cases should include deprecation warning verification

Category
Maintainability
Code Snippet
test "rev_fold" {
let ls = @list.of(["1", "2", "3", "4", "5"])
let el : @list.T[String] = @list.empty()
inspect(ls.rev().fold(fn(acc, x) { x + acc }, init=""), content="12345")
}
Recommendation
Consider adding test cases that verify deprecation warnings are properly emitted when using the deprecated methods
Reasoning
Testing deprecation warnings helps ensure the deprecation mechanism works correctly and helps catch any issues with the warning system

@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 7294

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 33 unchanged lines in 1 file lost coverage.
  • Overall coverage remained the same at 93.103%

Files with Coverage Reduction New Missed Lines %
list/list.mbt 33 86.61%
Totals Coverage Status
Change from base Build 7293: 0.0%
Covered Lines: 8572
Relevant Lines: 9207

💛 - Coveralls

@bobzhang bobzhang merged commit b65912b into main Jun 15, 2025
9 of 12 checks passed
@bobzhang bobzhang deleted the hongbo/get_rid_of_warnings branch June 15, 2025 13:21
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.

2 participants
0