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

fix: convert string objects in the CoffeeScript AST into string primitives #119

Merged

Conversation

alangpierce
Copy link
Member

Progress toward decaffeinate/decaffeinate#666

When the CoffeeScript lexer sees an identifier that is also a reserved word, it
will make it into a string object so that it can tack a .reserved property on
it. However, since string objects have subtle differences from strings (most
notably, === can't be used to compare contents), this caused problems much
later on in decaffeinate. This commit converts to a string primitive if
necessary in a few places where it seems like this may come up, although the
MemberAccessOp case is the only one where I know for sure that it can.

The new test correctly tests that the memberName value is a string primitive;
the comparison fails if it's a string object.

…tives

Progress toward decaffeinate/decaffeinate#666

When the CoffeeScript lexer sees an identifier that is also a reserved word, it
will make it into a string object so that it can tack a `.reserved` property on
it. However, since string objects have subtle differences from strings (most
notably, `===` can't be used to compare contents), this caused problems much
later on in decaffeinate. This commit converts to a string primitive if
necessary in a few places where it seems like this may come up, although the
MemberAccessOp case is the only one where I know for sure that it can.

The new test correctly tests that the `memberName` value is a string primitive;
the comparison fails if it's a string object.
Copy link
Collaborator

@eventualbuddha eventualbuddha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boo mutable boxed types.

@alangpierce alangpierce merged commit 2d3f67d into decaffeinate:master Dec 31, 2016
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

Successfully merging this pull request may close these issues.

2 participants