Skip to content

Hash of vec_slice() return value disagrees with base R equivalent (on R-devel) #2144

@wlandau

Description

@wlandau

On R-devel (2026-02-03), vec_slice() returns objects which hash differently from their base R equivalents. This may seem like an edge case, but targets depends on the ability to reliably hash slices, and its tests on R-devel are currently failing.

Reprex:

library(vectors)

x <- c(1L, 3L, 5L)
a <- 1L
b <- x[1L]
c <- vctrs::vec_slice(x, 1L)

identical(a, b) # TRUE
identical(a, c) # TRUE
identical(b, c) # TRUE

digest::digest(a) # "4b5630ee914e848e8d07221556b0a2fb"
digest::digest(b) # "4b5630ee914e848e8d07221556b0a2fb"
digest::digest(c) # "f7e26430e6335947766e82d7459e9d77" -- different!

I get the same result both with version 0.7.1 of vctrs (current CRAN) and with 94cea16. The hashes only agree if I switch back to R-release (4.5.2).

Session info
> sessioninfo::session_info()
─ Session info ──────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R Under development (unstable) (2026-02-03 r89375)
 os       Red Hat Enterprise Linux 9.7 (Plow)
 system   x86_64, linux-gnu
 ui       X11
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       America/Indiana/Indianapolis
 date     2026-02-06
 pandoc   2.14.0.3 @ /usr/bin/pandoc
 quarto   1.6.42 @ /home/CENSORED/.local/bin/quartoPackages ──────────────────────────────────────────────────────────────────────────────────────────
 package     * version    date (UTC) lib source
 cli           3.6.5      2025-04-23 [1] RSPM (R 4.6.0)
 digest        0.6.39     2025-11-19 [1] RSPM (R 4.6.0)
 rlang         1.1.7      2026-01-09 [1] RSPM (R 4.6.0)
 sessioninfo   1.2.3      2025-02-05 [1] RSPM (R 4.6.0)
 vctrs         0.7.1.9000 2026-02-06 [1] Github (r-lib/vctrs@94cea16)

 [1] /home/c240390/R-devel/library

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions