Closed Bug 514576 Opened 15 years ago Closed 15 years ago

ES5 strict mode: no 'with' statements permitted in strict mode code

Categories

(Core :: JavaScript Engine, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jimb, Assigned: jimb)

References

(Blocks 1 open bug)

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(1 file, 2 obsolete files)

From ES5 Annex C:

Strict mode code may not include a WithStatement. The occurrence of a WithStatement in such a context is an SyntaxError (12.10).
Hmm.  Back in bug 322430, we decided that warnings about 'with' statements were misguided with JSOPTION_STRICT enabled.  ES5 strict mode forbids 'with' statements.  How should a unified strictness regime behave?
Sorry, my memory fails me, but can you remind me of the separate bit somewhere that indicates ES5 strict mode (a static property of JSScript, presumably a new bitfield). That plus JSOPTION_STRICT could enable the warning, whereas just JSOPTION_STRICT would not. Then you pick your poison with option-setting and/or "use strict".

/be
Assignee: general → jim
Attachment #404910 - Flags: review?(mrbkap)
Depends on: 514585
Comment on attachment 404910 [details] [diff] [review]
Forbid 'with' statements in strict mode code.

I like this patch so much, I'm going to give it 2 +s. However, I do have a nitpick:
>+            return NULL;
>+        }
>         pn = NewParseNode(PN_BINARY, tc);

Please add  a newline before this assignment.
Attachment #404910 - Flags: review?(mrbkap)
Attachment #404910 - Flags: review+
(In reply to comment #4)
> (From update of attachment 404910 [details] [diff] [review])
> I like this patch so much, I'm going to give it 2 +s.

:)

> However, I do have a
> nitpick:
> >+            return NULL;
> >+        }
> >         pn = NewParseNode(PN_BINARY, tc);
> 
> Please add  a newline before this assignment.

Fixed --- thanks!
Code unchanged; just added tests.
Attachment #404910 - Attachment is obsolete: true
Attachment #406582 - Flags: review?(mrbkap)
Attachment #406582 - Flags: review?(mrbkap) → review+
Revised tests per jorendorff's and waldo's comments.
Attachment #406582 - Attachment is obsolete: true
http://hg.mozilla.org/tracemonkey/rev/80bdd2d441d1
Status: NEW → ASSIGNED
Whiteboard: fixed-in-tracemonkey
Flags: in-testsuite+
http://hg.mozilla.org/mozilla-central/rev/80bdd2d441d1
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Depends on: 541455
No longer depends on: 541455
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: