8000 Breaking Change: make String::op_get return Int by Yu-zh · Pull Request #1861 · moonbitlang/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
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

Merged
merged 1 commit into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
10000
Diff view
Diff view
2 changes: 1 addition & 1 deletion builtin/builtin.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ impl String {
get(String, Int) -> Char
length(String) -> Int
make(Int, Char) -> String
op_get(String, Int) -> Char
op_get(String, Int) -> Int
substring(String, start~ : Int = .., end? : Int) -> String
to_string(String) -> String
unsafe_char_at(String, Int) -> Char
Expand Down
15 changes: 6 additions & 9 deletions builtin/intrinsics.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -1723,15 +1723,12 @@ pub fn String::length(self : String) -> Int = "%string_length"
pub fn String::charcode_length(self : String) -> Int = "%string_length"

///|
/// Retrieves the character at the specified index in a string. Each character in
/// the string is represented as a UTF-16 code unit.
/// Retrieves the charcode (UTF-16 code unit) at the specified index in a string.
///
/// Parameters:
///
/// * `string` : The string from which to retrieve the character.
/// * `index` : The position in the string from which to retrieve the character.
///
/// Returns the character at the specified index.
/// * `string` : The string from which to retrieve the charcode.
/// * `index` : The position in the string from which to retrieve the charcode.
///
/// Throws a runtime error if `index` is negative or greater than or equal to the
/// length of the string.
Expand All @@ -1741,8 +1738,8 @@ pub fn String::charcode_length(self : String) -> Int = "%string_length"
/// ```moonbit
/// test "String::op_get" {
/// let s = "Hello, 世界!"
/// inspect!(s[0], content="H")
/// inspect!(s[7], content="")
/// inspect!(s[0].to_char(), content="Some('H')")
/// inspect!(s[7], content="19990")
/// }
///
/// test "panic String::op_get/out_of_bounds" {
Expand All @@ -1751,7 +1748,7 @@ pub fn String::charcode_length(self : String) -> Int = "%string_length"
/// }
/// ```
///
pub fn String::op_get(self : String, idx : Int) -> Char = "%string_get"
pub fn String::op_get(self : String, idx : Int) -> Int = "%string_get"

///|
/// Retrieves the character at the specified index in a string.
Expand Down
0