feat: add Object.same static method for reliable built-in equality
Introduce a new static method `Object.same(obj1, obj2)` that exposes the VM's built-in equality semantics (`wrenValuesEqual`) directly, bypassing any user-defined `==` overrides. This required creating a dedicated metaclass for Object (subclass of Class) to host the static method without polluting every class with a `same` method. The implementation wires up a new `Object metaclass` in the core initialization sequence, adjusts the class hierarchy setup order, and adds comprehensive tests covering value types, identity comparison, and verification that `Object.same` ignores custom `==` operators.
This commit is contained in:
@@ -5,5 +5,9 @@ IO.print(Foo.type.name) // expect: Foo metaclass
|
||||
|
||||
// Make sure the built-in classes have proper names too.
|
||||
IO.print(Object.name) // expect: Object
|
||||
IO.print(Class.name) // expect: Class
|
||||
IO.print(Bool.name) // expect: Bool
|
||||
IO.print(Class.name) // expect: Class
|
||||
|
||||
// And metaclass names.
|
||||
IO.print(Object.type.name) // expect: Object metaclass
|
||||
IO.print(Bool.type.name) // expect: Bool metaclass
|
||||
|
||||
Reference in New Issue
Block a user