-
Notifications
You must be signed in to change notification settings - Fork 186
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
Type coercion issue when to_str
raises NoMethodError
#2903
Comments
Right, it seems this is a problem for most I think unfortunately it's semantically incorrect in those cases to use a A possibility is to do it like |
Indeed it calls
|
Oh yeah it's really weird and full of corner cases:
So it does call |
Right, I think this is simply the "full" semantics of |
While working on getting the Sorbet test suite passing on TruffleRuby, @paracycle discovered an issue with some of our type coercion logic. In this case, an object is attempted to be coerced to a
String
viato_str
. Ifto_str
raises aNoMethodError
then some of our type coercion logic assumes the type cannot be converted and raises aTypeError
rather than theNoMethodError
.A brief search indicates
ToStringOrSymbolNode
needs to check if the method exists. Our logic inTruffle::Type.try_convert
does perform the extrarespond_to?
check, but it looks like that didn't get carried forward to type coercion performed in Java.MRI 3.1.3 (warnings removed):
TruffleRuby 23.0.0-dev (a671781, warnings removed):
The text was updated successfully, but these errors were encountered: