Skip to content

Add 'with' statement #462

Closed
wants to merge 4 commits into from

3 participants

@WolfgangKluge

Fix for #461.

@goatslacker
JSHint member

Trying to merge this in.

We'll need to change the warning message from 'with' should not be used... Never. to something else. I think 'with' should not be used. is good enough.

But just to play devil's advocate, why do we need the warning here in the first place, specially with no way to opt-out of it?

@WolfgangKluge

I agree, and I think (now), there are maybe even legitimate uses for with. So an option would be useful.
I thought, before this change, with leads to an error - so displaying an error message afterwards must be a quite good idea ;)
Will you implement it or should I?

@goatslacker
JSHint member

Go for it!

@WolfgangKluge

Name suggestions for the option? withwith ;)

@goatslacker
JSHint member

withstmt ?

@valueof valueof commented on an outdated diff Mar 5, 2012
@@ -3595,7 +3595,24 @@ loop: for (;;) {
return this;
}).labelled = true;
- reserve('with');
+ blockstmt('with', function () {
+ var t = nexttoken;
+ if (directive['use strict']) {
+ error("'with' is not allowed in strict mode code.", token);
@valueof
JSHint member
valueof added a note Mar 5, 2012

Could you rewrite this as 'with' is not allowed in strict mode..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@valueof valueof commented on an outdated diff Mar 5, 2012
@@ -3595,7 +3595,24 @@ loop: for (;;) {
return this;
}).labelled = true;
- reserve('with');
+ blockstmt('with', function () {
+ var t = nexttoken;
+ if (directive['use strict']) {
+ error("'with' is not allowed in strict mode code.", token);
+ } else {
+ warning("'with' should not be used... Never.", token);
@valueof
JSHint member
valueof added a note Mar 5, 2012

Don't use 'with'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@valueof
JSHint member
valueof commented Mar 5, 2012

+1 for withstmt.

@valueof valueof referenced this pull request Mar 5, 2012
Closed

with statement #461

@valueof
JSHint member
valueof commented Mar 7, 2012

Looks good to me—going to test and merge it in.

@valueof
JSHint member
valueof commented Mar 7, 2012

Merged: ef3fb59

@valueof valueof closed this Mar 7, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.