Fix for https://bugs.ruby-lang.org/issues/8771

https://bugs.ruby-lang.org/issues/8771