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

force_encoding locale and filesystem encodings throw NullPointerException #1397

Closed
medlefsen opened this issue Jul 24, 2018 · 4 comments
Closed
Assignees
Milestone

Comments

@medlefsen
Copy link

medlefsen commented Jul 24, 2018

Installed truffleruby via rvm (1.0.0-rc2).

In MRI Encoding::force_encoding supports 'locale' and 'filesystem' as bulit-in aliases for system locales.

https://ruby-doc.org/core-2.4.0/Encoding.html#class-Encoding-label-Locale+encoding

On truffleruby both of these lead to a NullPointerException:

truffleruby-1.0.0-rc2 :007 > "".force_encoding('locale')
RuntimeError: <no message> (NullPointerException)
	from org.truffleruby.core.encoding.EncodingLayoutImpl.isEncoding(EncodingLayoutImpl.java:101)
	from org.truffleruby.core.encoding.EncodingLayoutImpl.getEncoding(EncodingLayoutImpl.java:117)
	from org.truffleruby.core.encoding.EncodingOperations.getEncoding(EncodingOperations.java:22)
	from org.truffleruby.core.string.StringNodes$ForceEncodingNode.forceEncodingEncoding(StringNodes.java:1252)
	from org.truffleruby.core.string.StringNodes$ForceEncodingNode.forceEncodingString(StringNodes.java:1247)
	from org.truffleruby.core.string.StringNodesFactory$ForceEncodingNodeFactory$ForceEncodingNodeGen.executeAndSpecialize(StringNodesFactory.java:3456)
	from org.truffleruby.core.string.StringNodesFactory$ForceEncodingNodeFactory$ForceEncodingNodeGen.execute(StringNodesFactory.java:3439)
	from org.truffleruby.language.control.SequenceNode.execute(SequenceNode.java:34)
	from org.truffleruby.language.methods.ExceptionTranslatingNode.execute(ExceptionTranslatingNode.java:50)
	from org.truffleruby.language.RubyRootNode.execute(RubyRootNode.java:50)
Translated to internal error
	from (irb):7:in `force_encoding'
	from (irb):7:in `<top (required)>'

@medlefsen medlefsen changed the title locale and filesystem encodings throw NullPointerException force_encoding locale and filesystem encodings throw NullPointerException Jul 24, 2018
@nirvdrum nirvdrum self-assigned this Jul 24, 2018
@nirvdrum nirvdrum added this to the 1.0.0-rc5 milestone Jul 24, 2018
@nirvdrum
Copy link
Collaborator

Thanks for the helpful bug report! I'm a bit embarrassed this was an issue at all, but it's been fixed in f7a7a09. I've also added some specs for the Ruby Spec Suite to help ensure this doesn't regress and so other implementations can benefit from the extra tests.

The fix will appear in the next release (expected to be 1.0.0 RC5).

@medlefsen
Copy link
Author

Awesome, thanks for the super quick fix. Great project btw

@nirvdrum
Copy link
Collaborator

nirvdrum commented Aug 4, 2018

Thanks for the kind words. In case you hadn't seen, 1.0.0 RC5 has been released. If you get a chance, I'd love to verify that this issue has truly been fixed for you.

@medlefsen
Copy link
Author

medlefsen commented Aug 5, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants