From 7c61016c01a5709a646d8e38afd87c1a24181837 Mon Sep 17 00:00:00 2001 From: tufusa Date: Thu, 15 Jan 2026 15:06:39 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20`Object`=20=E3=81=AE=E3=83=A1?= =?UTF-8?q?=E3=82=BD=E3=83=83=E3=83=89=E3=82=92=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/object.rbs | 90 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/core/object.rbs b/core/object.rbs index 7a8c495..2a84af6 100644 --- a/core/object.rbs +++ b/core/object.rbs @@ -1,2 +1,92 @@ class Object < BasicObject + def !: () -> bool + def self.!: () -> bool + + def !=: (untyped other) -> bool + def self.!=: (untyped other) -> bool + + def <=>: (untyped other) -> bool + def self.<=>: (untyped other) -> bool + + def ==: (untyped other) -> bool + def self.==: (untyped other) -> bool + + def ===: (untyped other) -> bool + def self.===: (untyped other) -> bool + + def <: (untyped other) -> bool + + def <=: (untyped other) -> bool + + def >: (untyped other) -> bool + + def >=: (untyped other) -> bool + + def class: () -> class + def self.class: () -> class + + def dup: () -> self + def self.dup: () -> self + + def block_given?: () -> bool + + # TODO: Module + def kind_of?: (Class) -> bool + def self.kind_of?: (Class) -> bool + + alias is_a? kind_of? + alias self.is_a? self.kind_of? + + def nil?: () -> bool + def self.nil?: () -> bool + + # TODO: Array + def p: () -> nil + | [T](T arg0) -> T + + def print: (*untyped args) -> nil + + def puts: (*untyped args) -> nil + + # TODO Exception + def raise: () -> bot + | (String message) -> bot + # | (Exception) -> bot + # | (singleton(Exception)) -> bot + # | (Exception, String message) -> bot + # | (singleton(Exception), String message) -> bot + + # TODO: Symbol + # def self.attr_reader: (*String names) -> void + + # TODO: Symbol + # def self.attr_accessor: (*Symbol names) -> void + + # TODO: Module + # def include: (*Module mods) -> void + # def self.include: (*Module mods) -> void + # + # alias extend include + # alias self.extend include + + # TODO: Array, Symbol + # def self.constants: (?bool inherit) -> Array[Symbol] + + def self.public: () -> void + + def self.private: () -> void + + def self.protected: () -> void + + def sprintf: (String format, *untyped args) -> String + + def printf: (String format, *untyped args) -> nil + + def to_s: () -> String + def self.to_s: () -> String + + alias inspect to_s + alias self.inspect self.to_s + + def loop: () { () -> void } -> bot end From 07f2609a90e02b3f118f6f0e1e498969b1d88615 Mon Sep 17 00:00:00 2001 From: tufusa Date: Thu, 15 Jan 2026 15:06:55 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=E3=83=86=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/object.rb | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/test/object.rb b/test/object.rb index 8e9b8f9..2a828a3 100644 --- a/test/object.rb +++ b/test/object.rb @@ -1 +1,95 @@ # frozen_string_literal: true + +# rubocop:disable Lint/Void +# rubocop:disable Lint/UnreachableCode +# rubocop:disable Lint/UselessAccessModifier +# rubocop:disable Style/CaseEquality +# rubocop:disable Style/ClassCheck +# rubocop:disable Style/FormatString +# rubocop:disable Style/RedundantFormat + +object = Object.new + +!object +!Object + +object != true +Object != true + +object <=> true +Object <=> true + +object == true +Object == true + +object === true +Object === true + +object < 1 + +object <= 1 + +object > 1 + +object >= 1 + +object.class +Object.class + +object.dup +Object.dup + +block_given? +object.block_given? + +object.kind_of? Object +Object.kind_of? Object + +object.is_a? Object +Object.is_a? Object + +object.nil? +Object.nil? + +p +p 1 +object.p +object.p 1 + +print +print 1, true, 'a' +object.print +object.print 1, true, 'a' + +puts +puts 1, true, 'a' +object.puts +object.puts 1, true, 'a' + +raise +raise 'error' +object.raise +object.raise 'error' + +# @type const A: A +class A + public + + private + + protected +end + +sprintf "%d\n", 123 + +printf "%d\n", 123 + +object.to_s +Object.to_s + +object.inspect +Object.inspect + +loop { puts } + +# rubocop:enable all From 6db7d201c42e6daab8b264222ea0a05e7586237c Mon Sep 17 00:00:00 2001 From: tufusa Date: Thu, 15 Jan 2026 15:07:23 +0900 Subject: [PATCH 3/4] =?UTF-8?q?chore:=20`=3D=3D`,=20`!=3D`=20=E3=82=92=20`?= =?UTF-8?q?Object`=20=E3=81=8B=E3=82=89=E3=81=AE=E7=B6=99=E6=89=BF?= =?UTF-8?q?=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/float.rbs | 4 ---- core/integer.rbs | 4 ---- core/string.rbs | 4 ---- 3 files changed, 12 deletions(-) diff --git a/core/float.rbs b/core/float.rbs index 057d928..44d4481 100644 --- a/core/float.rbs +++ b/core/float.rbs @@ -13,10 +13,6 @@ class Float < Object def **: (Integer | Float) -> Float - def ==: (untyped other) -> bool - - def !=: (untyped other) -> bool - def <: (Integer | Float other) -> bool def <=: (Integer | Float other) -> bool diff --git a/core/integer.rbs b/core/integer.rbs index 5e96f19..ecfe803 100644 --- a/core/integer.rbs +++ b/core/integer.rbs @@ -34,10 +34,6 @@ class Integer < Object def >>: (Integer) -> Integer - def ==: (untyped other) -> bool - - def !=: (untyped other) -> bool - def <: (Integer | Float other) -> bool def <=: (Integer | Float other) -> bool diff --git a/core/string.rbs b/core/string.rbs index fadf996..1abbd72 100644 --- a/core/string.rbs +++ b/core/string.rbs @@ -1,10 +1,6 @@ class String < Object def initialize: (?String source) -> void - def ==: (untyped other) -> bool - - def !=: (untyped other) -> bool - def <: (String other) -> bool def <=: (String other) -> bool From 2d5f71513c9468885129c8acedd716dedcc2325a Mon Sep 17 00:00:00 2001 From: tufusa Date: Thu, 15 Jan 2026 15:25:49 +0900 Subject: [PATCH 4/4] chore: rubocop --- core/object.rbs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/object.rbs b/core/object.rbs index 2a84af6..f0a8776 100644 --- a/core/object.rbs +++ b/core/object.rbs @@ -23,7 +23,7 @@ class Object < BasicObject def >=: (untyped other) -> bool def class: () -> class - def self.class: () -> class + def self.class: () -> self def dup: () -> self def self.dup: () -> self @@ -61,14 +61,14 @@ class Object < BasicObject # TODO: Symbol # def self.attr_accessor: (*Symbol names) -> void - + # TODO: Module # def include: (*Module mods) -> void # def self.include: (*Module mods) -> void # # alias extend include # alias self.extend include - + # TODO: Array, Symbol # def self.constants: (?bool inherit) -> Array[Symbol]