natalie
natalie copied to clipboard
defined? should not call const_missing
I ran into this issue when working on #1733.
The specs of https://github.com/ruby/spec/blob/master/language/optional_assignments_spec.rb have the following code (simplified):
class ClassA
def self.const_missing(const)
const
end
OR_ASSIGNED_CONSTANT1 ||= :assigned
end
p ClassA::OR_ASSIGNED_CONSTANT1
This prints :assigned
in MRI, but ``:OR_ASSIGNED_CONSTANT1in Natalie. This code depends on
defined?`
p defined?(ClassA::NONE)
This prints nil
in MRI, but "constant"
in Natalie.
defined?
is not supposed to call const_missing
.