mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
A comment for typed data in rb_check_type
[ci skip]
This commit is contained in:
parent
d58620e0a1
commit
edd27e120e
Notes:
git
2021-08-14 23:12:27 +09:00
2 changed files with 9 additions and 3 deletions
8
error.c
8
error.c
|
@ -1007,6 +1007,14 @@ rb_check_type(VALUE x, int t)
|
||||||
|
|
||||||
xt = TYPE(x);
|
xt = TYPE(x);
|
||||||
if (xt != t || (xt == T_DATA && RTYPEDDATA_P(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);
|
unexpected_type(x, xt, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -340,9 +340,7 @@ Check_Type(VALUE v, enum ruby_value_type t)
|
||||||
goto unexpected_type;
|
goto unexpected_type;
|
||||||
}
|
}
|
||||||
else if (t == RUBY_T_DATA && rbimpl_rtypeddata_p(v)) {
|
else if (t == RUBY_T_DATA && rbimpl_rtypeddata_p(v)) {
|
||||||
/* The intention itself is not necessarily clear to me, but at least it
|
/* Typed data is not simple `T_DATA`, see `rb_check_type` */
|
||||||
* is intentional to rule out typed data here. See commit
|
|
||||||
* a7c32bf81d3391cfb78cfda278f469717d0fb794. */
|
|
||||||
goto unexpected_type;
|
goto unexpected_type;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue