feat: extend scan_na to cover all four NA-trap integer dtypes#195
Merged
Conversation
`scan_na = TRUE` in `as_array.PJRTBuffer` previously only checked `i32` for the `-2147483648`/`NA_integer_` collision. The same collision exists for `ui32` (`2^31` wraps to `INT_MIN`), `i64` (`-2^63 = INT64_MIN` is `bit64`'s `NA_integer64_`), and `ui64` (`2^63` wraps to `INT64_MIN`). Checking only `i32` left three identical silent-corruption channels open. The check now fires for any of the four integer dtypes when `anyNA()` on the materialized vector is true (`bit64::anyNA.integer64` correctly recognizes `INT64_MIN` as NA, so the same condition covers both 32- and 64-bit cases). The error message distinguishes the two bit patterns. Tests in test-buffer.R extended: planted-byte coverage for each of the four collisions, plus a "no-op for float/bool/small-integer" case. Default remains `FALSE` — anvl is the caller that chooses the safer default. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
scan_na = TRUEinas_array.PJRTBufferpreviously only checkedi32for the-2147483648/NA_integer_collision. The same collision exists forui32(2^31wraps toINT_MIN),i64(-2^63 = INT64_MINisbit64'sNA_integer64_), andui64(2^63wraps toINT64_MIN). Checking onlyi32left three identical silent-corruption channels open.The check now fires for any of the four integer dtypes when
anyNA()on the materialized vector is true (bit64::anyNA.integer64correctly recognizesINT64_MINas NA, so the same condition covers both 32- and 64-bit cases). The error message distinguishes the two bit patterns.Tests in test-buffer.R extended: planted-byte coverage for each of the four collisions, plus a "no-op for float/bool/small-integer" case. Default remains
FALSE— anvl is the caller that chooses the safer default.