Project

General

Profile

Actions

Backport #6578

closed

(Ruby 1.9.2-p290) Built-in JSON library fails if "Parser" is defined at top level

Added by alexdowad (Alex Dowad) almost 12 years ago. Updated almost 8 years ago.

Status:
Rejected
Assignee:
-
[ruby-core:45581]

Description

To duplicate:

class Parser
end
require 'json'

The culprit is line 27 of common/json.rb:

remove_const :Parser if const_defined? :Parser

#const_defined? returns true even if Parser is defined at the top level, not within JSON. In this case, #remove_const fails with an exception. A possible fix would be:

remove_const :Parser if constants.include? :Parser
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0