-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Difference between Ruby's Check_Type() and implementation in TruffleRuby #2307
Comments
Thanks for the great bug report. |
Hello, Just to add - prior to Ruby 3.0, the #define Check_Type(v, t) \
(!RB_TYPE_P((VALUE)(v), (t)) || \
((t) == RUBY_T_DATA && RTYPEDDATA_P(v)) ? \
rb_unexpected_type((VALUE)(v), (t)) : (void)0) N.B. This has no bearing on the message that Ruby would emit, whether it would be 2.7 or 3.0. Krzysztof |
@aardvark179 Could you look at this one? Probably we need some kind of mapping from |
Hi @eregon and @aardvark179,
Not sure if this helps, but I added a small helper to my Ruby Gem: Not sure if this was the best way, but does work and normalizes the type checking between Ruby and TruffleRuby a little bit, especially when it goes to error reporting. Krzysztof |
Signed-off-by: Stan Hu <stanhu@gmail.com>
@kwilczynski Fixed in ea82ff0 by @aardvark179 and myself. I would recommend switching to Or you can wait for the 20.2.0 release if you prefer, but that will be in a while, and I'm concerned we would forget about those workarounds: https://www.graalvm.org/release-notes/version-roadmap/ I think just skipping the couple failing tests on TruffleRuby <= 20.1.0 is also completely fine. |
Hi @eregon, Thank you for update! Also, apologies for making you and @aardvark179 do more work! I appreciate to fix, though. :) Re: Krzysztof |
Hi @eregon, sorry for late reply!
[...]
I was able to derive a small piece of code that can reproduce what I was talking about:
Running it against Ruby and TruffleRuby:
The function I am using is
Check_Type()
from include/ruby/internal/value_type.h#L329-L352:Which in Ruby is trying to do some internal optimisations to make the resolution a bit faster, but then it might end up calling the
rb_check_type()
from error.c#L984-L997:TruffleRuby also provides
Check_Type()
, albeit it's a macro (see: lib/cext/include/ruby/ruby.h#L664) that wrapsrb_check_type()
, as per:And the
rb_check_type()
is then defined (see: src/main/c/cext/object.c#L43-L45) as follows:I then found a bit of documentation on what might be happening internally:
cexts.md#c-runtime-implementation-details.
Should I go deeper into finding where things diverge, or would it be enough for you to decide whether this is something that you would consider something to potentially fix? Let me know. :)
Krzysztof
Originally posted by @kwilczynski in kwilczynski/ruby-magic#10 (comment)
The text was updated successfully, but these errors were encountered: