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

Inconsistency between comments and code implementation #5430

Closed
YichiZhang0613 opened this issue Feb 26, 2024 · 1 comment · Fixed by #5456
Closed

Inconsistency between comments and code implementation #5430

YichiZhang0613 opened this issue Feb 26, 2024 · 1 comment · Fixed by #5456
Labels
arrow Changes to the arrow crate bug documentation Improvements or additions to documentation good first issue Good for newcomers help wanted

Comments

@YichiZhang0613
Copy link
Contributor

I noticed a possible panic due to inconsistency between comments and code implementation in arrow-rs/arrow-array/src/array/union_array.rs. The details can be found in the following code.
I think this function should check whether index is out of bounds as your comment read before it is used as self.type_ids[index], which could avoid unnecessary panic.

   /// # Panics
    ///
    /// Panics if `index` is greater than the length of the array.
    pub fn type_id(&self, index: usize) -> i8 {
        self.type_ids[index]
    }

By the way, I think it would be more complete if the comment is modified to Panics if index is greater than or equal to the length of the array. instead of Panics if index is greater than the length of the array.

    /// # Panics
    ///
    /// Panics if `index` is greater than the length of the array.
    pub fn value_offset(&self, index: usize) -> usize {
        assert!(index < self.len());
@tustvold tustvold added documentation Improvements or additions to documentation good first issue Good for newcomers help wanted labels Feb 26, 2024
@tustvold tustvold added the arrow Changes to the arrow crate label Mar 15, 2024
@tustvold
Copy link
Contributor

label_issue.py automatically added labels {'arrow'} from #5456

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate bug documentation Improvements or additions to documentation good first issue Good for newcomers help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants