Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict const checks to current namespace to avoid conflict with globals #108

Merged
merged 1 commit into from
Jul 21, 2024

Conversation

rwstauner
Copy link
Contributor

Getting this error on latest master when a top-level Parser constant is defined before URI is loaded:

$ ruby -Ilib -e 'module Parser; end; require "uri/common"'
/Users/rwstauner/src/github.com/ruby/uri/lib/uri/common.rb:26:in `remove_const': constant URI::Parser not defined (NameError)

    remove_const(:Parser) if defined?(Parser)
    ^^^^^^^^^^^^
        from /Users/rwstauner/src/github.com/ruby/uri/lib/uri/common.rb:26:in `parser='
        from /Users/rwstauner/src/github.com/ruby/uri/lib/uri/common.rb:46:in `<module:URI>'
        from /Users/rwstauner/src/github.com/ruby/uri/lib/uri/common.rb:15:in `<top (required)>'
        from <internal:/Users/rwstauner/.rubies/3.3.0/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
        from <internal:/Users/rwstauner/.rubies/3.3.0/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
        from -e:1:in `<main>'

@rwstauner rwstauner changed the title Restrict Parser check to current namespace to avoid conflict with ::Parser Restrict const checks to current namespace to avoid conflict with globals Jul 20, 2024
@jeremyevans
Copy link
Contributor

Good work. Was about to submit the same pull request in response to Ruby bug 20644.

@jeremyevans jeremyevans merged commit 7a64e02 into ruby:master Jul 21, 2024
24 checks passed
@hsbt
Copy link
Member

hsbt commented Jul 21, 2024

👍 Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants