Skip to content

Enable early return for Ruby 4.1+ again#101

Open
hsbt wants to merge 1 commit intomasterfrom
skip-loading-gem-on-ruby-4.1
Open

Enable early return for Ruby 4.1+ again#101
hsbt wants to merge 1 commit intomasterfrom
skip-loading-gem-on-ruby-4.1

Conversation

@hsbt
Copy link
Copy Markdown
Member

@hsbt hsbt commented Apr 14, 2026

No description provided.

Copilot AI review requested due to automatic review settings April 14, 2026 07:33
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR attempts to skip loading lib/pathname.rb on Ruby 4.1+ (presumably because Pathname is fully provided elsewhere in those versions), by adding an early guard at the top of the file.

Changes:

  • Add a Ruby-version guard intended to short-circuit lib/pathname.rb on Ruby 4.1+.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +13 to +14
return if RUBY_VERSION >= '4.1'

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.
Comment on lines +13 to 15
return if RUBY_VERSION >= '4.1'

unless RUBY_VERSION >= '4'
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.
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.

2 participants