Skip to content

Conversation

@flavorjones
Copy link
Contributor

Previously 9eead86 introduced non-commutativity of platforms, and later commit 1b9f7f5 changed the behavior of Gem::Platform.match to ensure the callee of #=~ was the gem platform.

However, when the platform argument is a String, then the callee and argument of #=~ are flipped (see docs for String#=~), which works against the fix from 1b9f7f5.

Closes #5938

What was the end-user or developer problem that led to this PR?

See #5938

What is your fix for the problem, implemented in this PR?

Coerce the Gem::Platform.match argument to a Gem::Platform object

Make sure the following tasks are checked

Previously 9eead86 introduced non-commutativity of platforms, and
later commit 1b9f7f5 changed the behavior of `Gem::Platform.match` to
ensure the callee of `#=~` was the gem platform.

However, when the platform argument is a String, then the callee and
argument of `#=~` are flipped (see docs for `String#=~`), which works
against the fix from 1b9f7f5.

Closes ruby#5938
Copy link
Contributor

@deivid-rodriguez deivid-rodriguez left a comment

Choose a reason for hiding this comment

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

Looks good, thanks @flavorjones!

@deivid-rodriguez deivid-rodriguez changed the title fix: Gem::Platform.match handles String argument properly Fix Gem::Platform.match not handling String argument properly Sep 27, 2022
@deivid-rodriguez deivid-rodriguez merged commit fa391c6 into ruby:master Sep 27, 2022
@flavorjones flavorjones deleted the 5938-gem-platform-match-string-arg branch September 28, 2022 16:51
deivid-rodriguez added a commit that referenced this pull request Oct 5, 2022
…ing-arg

fix: Gem::Platform.match handles String argument properly
(cherry picked from commit fa391c6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gem::Platform.match no longer behaves properly with a String argument

2 participants