Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/pathname.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
# For documentation, see class Pathname.
#

return if RUBY_VERSION >= '4.1'

Comment on lines +13 to +14
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return at the top level of a required file is a syntax error in Ruby (invalid return in top-level context), so this change will prevent lib/pathname.rb from loading on all Ruby versions. If you need to skip the rest of the file for Ruby >= 4.1, wrap the remainder of the file in a conditional (if/unless) rather than using return.

Copilot uses AI. Check for mistakes.
unless RUBY_VERSION >= '4'
Comment on lines +13 to 15
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RUBY_VERSION is a string, so RUBY_VERSION >= '4.1' performs lexicographic comparison and can yield incorrect results for multi-digit segments (e.g., '4.10' vs '4.1'). Please use a numeric/semantic version comparison (e.g., Gem::Version, or comparing RUBY_VERSION.split('.').map(&:to_i) arrays) to make the guard correct for all future Ruby 4.x releases.

Suggested change
return if RUBY_VERSION >= '4.1'
unless RUBY_VERSION >= '4'
ruby_version = RUBY_VERSION.split('.').map(&:to_i)
return if ruby_version >= [4, 1]
unless ruby_version >= [4]

Copilot uses AI. Check for mistakes.
require 'pathname.so' if RUBY_ENGINE == 'ruby'

Expand Down
Loading