-
Notifications
You must be signed in to change notification settings - Fork 185
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
added Integer.try_convert, Ruby 3.1 support #2905
Conversation
Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application. When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated. If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public. |
Thank you for the PR, I will review after the OCA is through. |
bcb5269
to
e2bb77e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR, I'll do the finishing touches and run the internal CI on it.
It also needs a changelog entry, I'll add it.
@moste00 Which ruby version did you use to get the error message?
|
The CI tells us in https://github.com/oracle/truffleruby/actions/runs/4347779724/jobs/7611599985 |
e2bb77e
to
e40a400
Compare
* It's redundant with the spec above.
* Fix Truffle::Type.try_convert message to match CRuby. * Spec the message for all .try_convert TypeErrors.
e40a400
to
6876cd3
Compare
I was having problems with my distro's apt when I added the specs testing the error message, it seemed to think that ruby 3.0 is the newest version and no amount of updating or upgrading will change its mind. As a temp workaround I used this website https://try.ruby-lang.org/, which, now that I have the idea to run "puts RUBY_VERSION", uses ruby 3.2 under the hood. I apologize for not noticing this earlier, and for not using my local 3.1 as soon as I got it working. As a curious observation, CRuby changed the error message going from 3.1 to 3.2 without inlcuding this in the release docs or any other docs I'm aware of (or did they ?), the error message also appears to be inconsistent : in ruby 3.1, passing an Object.new that mocks :to_int to return an empty string gives the same standard message as any other non-Integer object (using "to"), but in ruby 3.2, the empty string in particular gets the response "no implicit conversion of Object into Integer", other strings and Object.new get the usual response with "into". Maybe there is an official subtlety in the type system somewhere that says the empty string in particular should get this particular response, but more likely it seems to me that this is just an implementation detail. It seems also that CRuby doesn't regard error messages as part of the API, this might be an explanation for why nobody wrote a spec to test the message till now. So should we even regard error messages as API-visible changes when CRuby itself doesn't ? Is it plausible that someone is "depending" on the error message being this exact same string somehow ? I don't know, but I think it's low probability. |
https://try.ruby-lang.org/ is using Opal and not CRuby, you can see that with:
And Opal is not fully compatible, e.g. they have a different message there. |
Fixed an issue listed in #2733, namely the addition of a method try_convert to the class Integer, spec is in spec/ruby/core/integer/try_convert_spec.rb.