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

Convert ~ and ! prefix tokens to esprima #276

Merged
merged 1 commit into from
May 27, 2016
Merged

Convert ~ and ! prefix tokens to esprima #276

merged 1 commit into from
May 27, 2016

Conversation

danez
Copy link
Contributor

@danez danez commented May 26, 2016

The two prefixes are now converted to Punctator like esprima is returning them.

fixes #274

type.isAssign) {

type.isAssign ||
(type.prefix && (token.value === "~" || token.value === "!"))
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to filter further if type.prefix is true? Is there ever a situation where a prefix isn't a punctuation? Or are there other punctuator prefixes that this should also cover?

Copy link
Contributor Author

@danez danez May 26, 2016

Choose a reason for hiding this comment

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

I looked through the acorn code and I'm pretty sure that currently if type.prefix is true, the value is either ! or ~. I only added the value comparison, so that in future if acorn adds another prefix (which might not be a Punctator?) it is not immediately converted to Punctator.

Do you think it is safe to assume that prefix is always a Punctator?

Copy link
Member

Choose a reason for hiding this comment

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

I think you can safely say if the first character of the token is not an identifier start, then it's a punctuator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just checked again: typeof, void and delete are also prefixes. So a differentiation is necessary.

@danez
Copy link
Contributor Author

danez commented May 26, 2016

It seems that my change also makes the testsuite hang on the XMLHttpRequest test.

I can't figure out why my change is breaking stuff.

Actually it looks like the assert is hanging when comparing the results.

@danez
Copy link
Contributor Author

danez commented May 27, 2016

I finally fixed the tests. They were hanging because i forgot to update the library results and assert can't handle diffs that big.

@nzakas
Copy link
Member

nzakas commented May 27, 2016

This looks great, thanks! I'll do a release later today.

@nzakas nzakas merged commit 7df2e4a into eslint:master May 27, 2016
@danez danez deleted the fix-prefix-type branch May 28, 2016 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exclamation mark has acorn token type
3 participants