truffleruby icon indicating copy to clipboard operation
truffleruby copied to clipboard

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

Open postmodern opened this issue 2 years ago • 3 comments

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)

postmodern avatar Nov 21 '22 13:11 postmodern

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.

nirvdrum avatar Nov 21 '22 13:11 nirvdrum

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

postmodern avatar Nov 21 '22 13:11 postmodern

Thank you for report.

andrykonchin avatar Nov 21 '22 15:11 andrykonchin