Skip to content

feat: extend scan_na to cover all four NA-trap integer dtypes#195

Merged
sebffischer merged 1 commit into
mainfrom
feat/scan-na-all-int-dtypes
May 18, 2026
Merged

feat: extend scan_na to cover all four NA-trap integer dtypes#195
sebffischer merged 1 commit into
mainfrom
feat/scan-na-all-int-dtypes

Conversation

@sebffischer
Copy link
Copy Markdown
Collaborator

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.

`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>
@sebffischer sebffischer merged commit 46d6920 into main May 18, 2026
13 of 14 checks passed
@sebffischer sebffischer deleted the feat/scan-na-all-int-dtypes branch May 18, 2026 12:10
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.

1 participant