A villager could not walk across a rail to get to a bed once that rail is straight and long enough. Or, if the rail is circled around the bed, and the villager is outside of the rail, he(she/it) cannot get to the bed either.
Environment
OS: Arch Linux
Kernel: x86_64 Linux 5.15.91-4-lts
CPU: 12th Gen Intel Core i5-12600KF @ 16x 4.9GHz
GPU: AMD/ATI Navi 24 [Radeon RX 6400/6500 XT/6500M]
RAM: 10352MiB / 31916MiB
openjdk version "1.8.0_362"
OpenJDK Runtime Environment (build 1.8.0_362-b09)
OpenJDK 64-Bit Server VM (build 25.362-b09, mixed mode)
Duplicate of MC-33359