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

Exception message mismatch on invalid symbol encoding #2850

Closed
nirvdrum opened this issue Feb 3, 2023 · 1 comment
Closed

Exception message mismatch on invalid symbol encoding #2850

nirvdrum opened this issue Feb 3, 2023 · 1 comment

Comments

@nirvdrum
Copy link
Collaborator

nirvdrum commented Feb 3, 2023

While pairing with @st0012 on removing TruffleRuby exclusions from the IRB test suite, we ran into a case where TruffleRuby uses a slightly different exception message than MRI when constructing a symbol from an invalid key. While error messages aren't exactly stable, I think we should try to match MRI where we can do so without too much effort.

MRI 3.1.3:

> ruby -v -e ':"\xAE"'
ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [arm64-darwin21]
ruby: invalid symbol in encoding UTF-8 :"\\xAE" (EncodingError)

> ruby -v -e '"\xAE".to_sym'
ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [arm64-darwin21]
-e:1:in `to_sym': invalid symbol in encoding UTF-8 :"\\xAE" (EncodingError)
        from -e:1:in `<main>'

MRI 3.2.0:

ruby -v -e ':"\xAE"'
ruby 3.2.0 (2022-12-25 revision a528908271) [arm64-darwin21.5.0]
ruby: invalid symbol in encoding UTF-8 :"\xAE" (EncodingError)

> ruby -v -e '"\xAE".to_sym'
ruby 3.2.0 (2022-12-25 revision a528908271) [arm64-darwin21.5.0]
-e:1:in `to_sym': invalid symbol in encoding UTF-8 :"\xAE" (EncodingError)
        from -e:1:in `<main>'

TruffleRuby 23.0.0-dev:

> jt ruby -v -e ':"\xAE"'
truffleruby 23.0.0-dev-8bb04d8c, like ruby 3.1.3, GraalVM CE JVM [aarch64-darwin]
truffleruby: invalid encoding symbol (EncodingError)

> jt ruby -v -e '"\xAE".to_sym'
truffleruby 23.0.0-dev-8bb04d8c, like ruby 3.1.3, GraalVM CE JVM [aarch64-darwin]
<internal:core> core/string.rb:155:in `to_sym': invalid encoding symbol (EncodingError)
        from -e:1:in `<main>'

I've tried several versions of MRI going back to 2.7.5 and they all use the same message. If it's a historical divergence, it happened a while ago.

@andrykonchin
Copy link
Member

Fixed in 145d23e

@andrykonchin andrykonchin added this to the 23.0.0 Release milestone Feb 8, 2023
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

2 participants