Skip to content
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

Zed_utf8.next_error: raise Zed_utf8.Out_of_bounds in case of invalid offset. #52

Merged
merged 2 commits into from
Jun 20, 2023

Conversation

Lucccyo
Copy link
Contributor

@Lucccyo Lucccyo commented Feb 17, 2023

Zed_utf8.next_error string offset should fail with Zed_utf8.Out_of_bounds, when offset does not belong to a valid range (from 0 to string's length).

@Lucccyo Lucccyo force-pushed the next_error_out_of_bounds branch from 1fcf3da to 34a102c Compare February 17, 2023 13:38
@Lucccyo Lucccyo force-pushed the next_error_out_of_bounds branch from c82b028 to 0d927c3 Compare March 3, 2023 07:40
src/zed_utf8.mli Outdated
Comment on lines 49 to 53
[ofs] is [String.length str] and [msg] is the empty string.
@raise [Zed_utf8.Out_of_bounds] if [ofs] not an index of [str].
*)
Copy link
Collaborator

@tmattio tmattio Mar 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[ofs] is [String.length str] and [msg] is the empty string.
@raise [Zed_utf8.Out_of_bounds] if [ofs] not an index of [str].
*)
[ofs] is [String.length str] and [msg] is the empty string.
@raise [Zed_utf8.Out_of_bounds] if [ofs] is not an index of [str]. *)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function seems to be raising Invalid as well, could you add it to the documentation at the same time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

@Lucccyo Lucccyo force-pushed the next_error_out_of_bounds branch from fe2d1e8 to 15925e3 Compare March 7, 2023 08:56
src/zed_utf8.mli Outdated
Comment on lines 51 to 53
@raise [Zed_utf8.Invalid] if [str] is not a correct UTF8 sequence.
@raise [Zed_utf8.Out_of_bounds] if [ofs] not an index of [str].
*)
Copy link
Collaborator

@tmattio tmattio Mar 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small formatting fix:

Suggested change
@raise [Zed_utf8.Invalid] if [str] is not a correct UTF8 sequence.
@raise [Zed_utf8.Out_of_bounds] if [ofs] not an index of [str].
*)
@raise [Zed_utf8.Invalid] if [str] is not a correct UTF8 sequence.
@raise [Zed_utf8.Out_of_bounds] if [ofs] not an index of [str]. *)

@Lucccyo Lucccyo force-pushed the next_error_out_of_bounds branch from 15925e3 to 3e9e005 Compare March 7, 2023 14:57
@emillon
Copy link
Contributor

emillon commented Jun 20, 2023

Looks good to me too.

@tmattio tmattio merged commit 8c29d3b into ocaml-community:master Jun 20, 2023
tmattio added a commit to tmattio/opam-repository that referenced this pull request Jun 20, 2023
CHANGES:

* `Zed_utf8.next_error`: raise `Zed_utf8.Out_of_bounds` in case of invalid offset (@Lucccyo, ocaml-community/zed#52)
* `kill_next_word` should not raise `Out_of_bound` (@Lucccyo, ocaml-community/zed#55)
* `of_utf8`: add `Uchar.is_valid` to check the input (@Lucccyo, ocaml-community/zed#51)
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