[前][次][番号順一覧][スレッド一覧]

ruby-changes:73948

From: Jean <ko1@a...>
Date: Mon, 10 Oct 2022 18:35:42 +0900 (JST)
Subject: [ruby-changes:73948] 1a7e7bb2d1 (master): object.c: rb_eql returns int not VALUE

https://git.ruby-lang.org/ruby.git/commit/?id=1a7e7bb2d1

From 1a7e7bb2d1dd507a6fdf883548633bdd14bf6854 Mon Sep 17 00:00:00 2001
From: Jean Boussier <byroot@r...>
Date: Fri, 7 Oct 2022 14:44:13 +0200
Subject: object.c: rb_eql returns int not VALUE

It works, but assumes `Qfalse == 0`, which is true today
but might not be forever.
---
 include/ruby/internal/intern/object.h | 4 ++--
 object.c                              | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/ruby/internal/intern/object.h b/include/ruby/internal/intern/object.h
index 19af49b140..b9ffa57c06 100644
--- a/include/ruby/internal/intern/object.h
+++ b/include/ruby/internal/intern/object.h
@@ -92,8 +92,8 @@ VALUE rb_class_new_instance_kw(int argc, const VALUE *argv, VALUE klass, int kw_ https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/intern/object.h#L92
  *
  * @param[in]  lhs          Comparison left hand side.
  * @param[in]  rhs          Comparison right hand side.
- * @retval     RUBY_Qtrue   They are equal.
- * @retval     RUBY_Qfalse  Otherwise.
+ * @retval     non-zero     They are equal.
+ * @retval     0            Otherwise.
  * @note       This  function  actually  calls `lhs.eql?(rhs)`  so  you  cannot
  *             implement your class' `#eql?` method using it.
  */
diff --git a/object.c b/object.c
index 2328b20757..c47d9ab3b2 100644
--- a/object.c
+++ b/object.c
@@ -134,12 +134,12 @@ rb_eql(VALUE obj1, VALUE obj2) https://github.com/ruby/ruby/blob/trunk/object.c#L134
 {
     VALUE result;
 
-    if (obj1 == obj2) return Qtrue;
+    if (obj1 == obj2) return TRUE;
     result = rb_eql_opt(obj1, obj2);
     if (result == Qundef) {
         result = rb_funcall(obj1, id_eql, 1, obj2);
     }
-    return RBOOL(RTEST(result));
+    return RTEST(result);
 }
 
 /**
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]