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

Store unescaped content in StringLiteral.value and raw content in StringLiteral.raw #203

Merged
merged 4 commits into from
Nov 8, 2018

Conversation

stasm
Copy link
Contributor

@stasm stasm commented Nov 6, 2018

This also forbids escape sequences representing surrogate code points, following @Pike's suggestion from #194 (comment). If we allow them, then their handling becomes environment/implementation dependent. E.g. they are ill-formed in the UTF-8 encoding.

Copy link
Contributor

@Pike Pike left a comment

Choose a reason for hiding this comment

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

I'm using .val and .raw_val in compare-locales, and I'm very unhappy about that. Just yesterday had to change one for the other, because the difference isn't obvious.

That said, maybe that's OK within this context, but we'll need comments for that.

Also, please keep the current semantics of .value, as most tools use that and will want to continue to use that.
How about .format_value or .bundle_value for the unescaped value? That indicates the API in which to use that variant?

@stasm
Copy link
Contributor Author

stasm commented Nov 6, 2018

That said, maybe that's OK within this context, but we'll need comments for that.

Where would you put it?

Also, please keep the current semantics of .value, as most tools use that and will want to continue to use that.

Tools will need to be updated anyways for Syntax 08, right? That's not a good reason for not making this change.

I prefer to call out the special-ness of the raw value field, which is why I called it raw. And then value is the unescaped one. That's the naming everyone in #195 have been using and also what I've seen in many other ASTs.

If you feel very strongly about this, I guess we could keep value as the raw one, and add unescaped for the unescaped one.

@Pike
Copy link
Contributor

Pike commented Nov 6, 2018

Where would you put it?

In ast.mjs, so that consumers of that API know what to use when.

@stasm stasm requested a review from Pike November 6, 2018 13:35
@Pike
Copy link
Contributor

Pike commented Nov 8, 2018

This is technically OK, but I disagree with the choice out of my own experience in compare-locales.

Practically, this is going to add a significant risk in particular to the Pontoon support, as we're changing the data the existing .value API returns.

Not going to block this, but also not going to r+ this, so removing myself from the review.

@Pike Pike removed their request for review November 8, 2018 10:47
@Pike
Copy link
Contributor

Pike commented Nov 8, 2018

Meh, can't find a way to actually remove myself without showing my previous r-.

@stasm
Copy link
Contributor Author

stasm commented Nov 8, 2018

Practically, this is going to add a significant risk in particular to the Pontoon support, as we're changing the data the existing .value API returns.

Thank you for you comment. I think I'm misunderstanding something here. When we update Pontoon to Syntax 0.8, we'll change the code which deals with StringLiterals to use the .raw field rather than .value. It sounds like this will solve this problem completely. We'll need to make changes to tools anyways. Is there more to this which I'm not seeing?

@stasm
Copy link
Contributor Author

stasm commented Nov 8, 2018

Actually, it looks like updating the serializer to use .raw for StringLiterals (which we'll need to do anyways) will be enough for Pontoon: https://github.com/mozilla/pontoon/blob/d55d260554d13173e4ee39629becbd0ab3a264af/pontoon/base/static/js/fluent_interface.js#L435.

@Pike
Copy link
Contributor

Pike commented Nov 8, 2018

My point is that I made the same exact API decision, and it's been a source of bugs (just this week, actually).

That said, I don't want to spend more time on this ticket.

@stasm
Copy link
Contributor Author

stasm commented Nov 8, 2018

OK, thanks again. I'm going to merge this as-is.

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