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

Parser is confused about delete statement #387

Closed
goatslacker opened this issue Dec 16, 2011 · 25 comments
Closed

Parser is confused about delete statement #387

goatslacker opened this issue Dec 16, 2011 · 25 comments

Comments

@goatslacker
Copy link
Member

var foo = 1;
delete foo;

It tells me I shouldn't delete variables, that's fine.

However,

var foo = 1 // <--- it's missing the semicolon
delete foo;

Makes the parser all confused.

3 3 'Expected an operator and instead saw 'delete'.'
3 9 'Missing semicolon.'
3 10 'Expected an assignment or function call and instead saw an expression.'

@WolfgangKluge
Copy link
Contributor

I think the automatic semicolon insertion should be one part, the new parser has to implement exactly as defined in ecma standard ;)

@xjamundx
Copy link

I'm having some issues with this:

var flat = tag.toObject()
delete flat._id

I get these errors. Just wanted to make sure that makes sense:

Expected an operator and instead saw 'delete'.
Expected an assignment or function call and instead saw an expression.

I have asi turned to true.

@adardesign
Copy link

I have
delete app.init.queue[prop];

and it throws "Expected an operator and instead saw 'delete'."

What should be a better way of writing this statement?

@hkjels
Copy link

hkjels commented May 7, 2012

Curios about this one myself.

@kilianc
Copy link

kilianc commented Jun 11, 2012

+1

@Raynos
Copy link
Contributor

Raynos commented Jun 26, 2012

This is rather annoying.

@danmilon
Copy link

danmilon commented Aug 8, 2012

affected by this also. Is there a workaround?

@Raynos
Copy link
Contributor

Raynos commented Aug 8, 2012

@danmilon prefix your delete statements with ;

@danmilon
Copy link

danmilon commented Aug 9, 2012

That will obviously not trigger the bug, but still, uglifying my code to silent jshint is not appropriate. I will try to parse the output, identify the errors caused by this bug, and clear them out.

Do you know if this is fixed on master?

@Raynos
Copy link
Contributor

Raynos commented Aug 9, 2012

@danmilon as far as I know it's not. Right now I make my code ugly to satisfy jshint as I rarely use the delete keyword. I'd rather have false positives rather then lose real errors in my JSHINT

@valueof
Copy link
Member

valueof commented Aug 29, 2012

Closing this as wontfix for this tree. Too much PITA to fix and is not a problem in Next.

@valueof valueof closed this as completed Aug 29, 2012
@Raynos
Copy link
Contributor

Raynos commented Aug 29, 2012

@antonkovalyov what do you mean its not a problem in Next?

@valueof
Copy link
Member

valueof commented Aug 30, 2012

Next uses Esprima as its JavaScript parser and Esprima can handle any valid ES5 code.

@goatslacker
Copy link
Member Author

This is Next btw

@cblage
Copy link

cblage commented Feb 19, 2013

Any news on this? It's still a problem.

@anupam11
Copy link

Still facing the same, any news on this, will it be fixed ?

@mikefrey
Copy link

@antonkovalyov Thoughts on re-opening this bug?

@robraux
Copy link

robraux commented Mar 1, 2013

+1

1 similar comment
@Raynos
Copy link
Contributor

Raynos commented Mar 2, 2013

👍

@mhart
Copy link

mhart commented Apr 23, 2013

@antonkovalyov This is still a problem in the latest version, v1.1.0 - are you saying that this version does not have the code from Next yet? Over at Next it says that it has now been merged into the main repository, so it's unclear what we should do.

How do we get around this issue? It's quite annoying.

@jonathanong
Copy link

+1

@Raynos
Copy link
Contributor

Raynos commented May 10, 2013

@antonkovalyov still an issue here.

👍

@philipwalton
Copy link

Still an issue for me as well with 2.1.2

@mhart
Copy link

mhart commented May 27, 2013

@antonkovalyov Can you please reopen this? Or should we file a new issue?

@usrbincc
Copy link
Contributor

Just a quick heads-up.

I ended up having to fix this very issue in a patch I did to get jshint to parse yield expressions correctly. I'll add a unit test for this once I finish up the unit tests for the patch itself.

I should have a pull request up by tomorrow.

usrbincc added a commit to usrbincc/jshint that referenced this issue May 29, 2013
valueof added a commit that referenced this issue Jun 26, 2013
valueof pushed a commit that referenced this issue Jun 26, 2013
jugglinmike pushed a commit to jugglinmike/jshint that referenced this issue Oct 21, 2014
ankitimaginea pushed a commit to ankitimaginea/fixmyjs that referenced this issue Nov 20, 2014
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 a pull request may close this issue.