From: "alexdowad (Alex Dowad)" Date: 2012-06-12T19:06:19+09:00 Subject: [ruby-core:45581] [ruby-trunk - Bug #6578][Open] (Ruby 1.9.2-p290) Built-in JSON library fails if "Parser" is defined at top level Issue #6578 has been reported by alexdowad (Alex Dowad). ---------------------------------------- Bug #6578: (Ruby 1.9.2-p290) Built-in JSON library fails if "Parser" is defined at top level https://bugs.ruby-lang.org/issues/6578 Author: alexdowad (Alex Dowad) Status: Open Priority: Normal Assignee: Category: Target version: 1.9.2 ruby -v: ruby 1.9.2p290 (2011-07-09) [i386-mingw32] 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 -- http://bugs.ruby-lang.org/