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

ruby-changes:67155

From: Nobuyoshi <ko1@a...>
Date: Sat, 14 Aug 2021 23:12:24 +0900 (JST)
Subject: [ruby-changes:67155] edd27e120e (master): A comment for typed data in `rb_check_type` [ci skip]

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

From edd27e120eca13be1754d4111dfc3cf2ab2f99f8 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sat, 14 Aug 2021 10:14:51 +0900
Subject: A comment for typed data in `rb_check_type` [ci skip]

---
 error.c                            | 8 ++++++++
 include/ruby/internal/value_type.h | 4 +---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/error.c b/error.c
index 5ac0f09..ef01e94 100644
--- a/error.c
+++ b/error.c
@@ -1007,6 +1007,14 @@ rb_check_type(VALUE x, int t) https://github.com/ruby/ruby/blob/trunk/error.c#L1007
 
     xt = TYPE(x);
     if (xt != t || (xt == T_DATA && RTYPEDDATA_P(x))) {
+        /*
+         * Typed data is not simple `T_DATA`, but in a sense an
+         * extension of `struct RVALUE`, which are incompatible with
+         * each other except when inherited.
+         *
+         * So it is not enough to just check `T_DATA`, it must be
+         * identified by its `type` using `Check_TypedStruct` instead.
+         */
 	unexpected_type(x, xt, t);
     }
 }
diff --git a/include/ruby/internal/value_type.h b/include/ruby/internal/value_type.h
index 790fc3b..5642686 100644
--- a/include/ruby/internal/value_type.h
+++ b/include/ruby/internal/value_type.h
@@ -340,9 +340,7 @@ Check_Type(VALUE v, enum ruby_value_type t) https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/value_type.h#L340
         goto unexpected_type;
     }
     else if (t == RUBY_T_DATA && rbimpl_rtypeddata_p(v)) {
-        /* The intention itself is not necessarily clear to me, but at least it
-         * is  intentional   to  rule   out  typed   data  here.    See  commit
-         * a7c32bf81d3391cfb78cfda278f469717d0fb794. */
+        /* Typed data is not simple `T_DATA`, see `rb_check_type` */
         goto unexpected_type;
     }
     else {
-- 
cgit v1.1


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

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