Skip to content
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

Integer#chr has different RangeError exception message compared to CRuby #2795

Closed
postmodern opened this issue Nov 21, 2022 · 3 comments
Closed

Comments

@postmodern
Copy link

postmodern commented Nov 21, 2022

I noticed a slight difference between TruffleRuby 22.3.0 and CRuby 3.0.4 while running my test suite against TruffleRuby. When Integer#chr tries to convert an invalid byte (ex: -1) into a character, the RangeError exception message is slightly different on TruffleRuby.

CRuby 3.0.4

-1.chr
# -1 out of char range (RangeError)

TruffleRuby 22.3.0

-1.chr
# -1 is outside of the valid character range (RangeError)
@nirvdrum
Copy link
Collaborator

FYI, it looks like you mixed up the attribution. Every version of MRI I tried prints out "-1 out of char range" while TruffleRuby prints out "-1 is outside of the valid character range".

This looks like something we inherited from Rubinius. It's a bit unfortunate because I think the Rubinius message is more helpful. Since MRI has historically changed exception messages at various times, the Ruby Spec Suite specs largely do not check for exact messages, just the exception type and sometimes a message fragment. With that said, we could make this one match MRI, trivially.

@postmodern
Copy link
Author

@nirvdrum oops you're right. I still haven't had my coffee yet.

@andrykonchin andrykonchin self-assigned this Nov 21, 2022
@andrykonchin
Copy link
Member

Thank you for report.

andrykonchin added a commit to ruby/spec that referenced this issue Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants