Skip to content

Breaking Change: make String::op_get return Int #1861

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Yu-zh
Copy link
Collaborator

@Yu-zh Yu-zh commented Apr 1, 2025

No description provided.

Copy link

peter-jerry-ye-code-review bot commented Apr 1, 2025

Type signature update needs matching documentation update

Category
Correctness
Code Snippet
pub fn String::op_get(self : String, idx : Int) -> Int = "%string_get"
Recommendation
Add documentation explaining that the function now returns the Unicode code point (as Int) instead of the character
Reasoning
The change from Char to Int return type is significant and should be clearly documented to avoid confusion for users of the API

Interface consistency between String::get and String::op_get

Category
Maintainability
Code Snippet
get(String, Int) -> Char
op_get(String, Int) -> Int
Recommendation
Consider aligning the behavior of get() and op_get(), or document why they return different types for the same operation
Reasoning
Having two similar indexing operations that return different types (Char vs Int) could be confusing for users. The difference in behavior should be justified and documented

Test cases could be more comprehensive

Category
Maintainability
Code Snippet
test "String::op_get" {
inspect!(s[0], content="72")
inspect!(s[7], content="19990")
}
Recommendation
Add test cases for non-ASCII characters in different positions, and edge cases like the last character in the string
Reasoning
Current tests only check two specific cases. More comprehensive testing would ensure the behavior is correct across different character types and positions

@coveralls
Copy link
Collaborator

coveralls commented Apr 1, 2025

Pull Request Test Coverage Report for Build 6524

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 92.736%

Totals Coverage Status
Change from base Build 6521: 0.0%
Covered Lines: 6128
Relevant Lines: 6608

💛 - Coveralls

@Yu-zh Yu-zh force-pushed the change-type-of-string-op-get branch from 59d61c2 to 67deb0e Compare April 1, 2025 14:02
@Yu-zh Yu-zh marked this pull request as draft April 1, 2025 14:07
@Yu-zh Yu-zh force-pushed the change-type-of-string-op-get branch from 67deb0e to cb61835 Compare April 2, 2025 07:22
@Yu-zh Yu-zh marked this pull request as ready for review April 7, 2025 03:41
@Yu-zh Yu-zh marked this pull request as draft April 7, 2025 06:26
@Yu-zh Yu-zh force-pushed the change-type-of-string-op-get branch from 168961c to ad416ee Compare April 11, 2025 08:11
@Yu-zh Yu-zh marked this pull request as ready for review April 14, 2025 02:01
@bobzhang bobzhang force-pushed the change-type-of-string-op-get branch from e4cb96d to b1f5574 Compare April 15, 2025 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants