Skip to content

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants