Bug 47672 - ES5 strict mode bugs
Summary: ES5 strict mode bugs
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.6
: P2 Normal
Assignee: Nobody
URL: http://kangax.github.com/es5-compat-t...
Keywords:
Depends on: 47788 47791 47833
Blocks:
  Show dependency treegraph
 
Reported: 2010-10-14 08:37 PDT by kangax
Modified: 2011-06-17 00:30 PDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kangax 2010-10-14 08:37:40 PDT
There are 3 oversights in the way strict mode works in webkit, which results in 4 failing tests with the above example page — http://kangax.github.com/es5-compat-table/strict-mode/

Also, for the ref, early error on "assignment to an unresolved reference" was discussed here — https://mail.mozilla.org/pipermail/es5-discuss/2010-October/003742.html
Comment 1 Alexey Proskuryakov 2010-10-15 14:36:54 PDT
The tests being:

__i_dont_exist = 1; is a ReferenceError
arguments++; is a SyntaxError
(function(){ return this === undefined; })();
(function(){ return this === undefined; }).call();
Comment 2 Oliver Hunt 2010-10-17 16:26:39 PDT
Fixing the reference error for global properties at the moment
Comment 3 Oliver Hunt 2010-10-17 21:18:28 PDT
__i_dont_exist = blah should now be fixed.
Comment 4 Oliver Hunt 2010-10-17 22:43:46 PDT
pre-/post-fix operations on arguments are now disallowed.
Comment 5 Oliver Hunt 2010-10-18 10:21:10 PDT
i've got the null vs. undefined |this| fix up for review now
Comment 6 Oliver Hunt 2010-10-18 11:33:47 PDT
And now the undefined vs null patch is landed.

kangax are there any other problems you've found?
Comment 7 kangax 2010-10-18 13:04:38 PDT
Hey Oliver.

I don't have this fresh build yet, but the previous one seems to also fail to set strict mode for eval code (in certain cases). For example:

(function(){ "use strict"; eval('with({ }) { }') })(); // no error

To quote 10.1.1:

"Eval code is strict eval code if it begins with a Directive Prologue that contains a Use Strict Directive or if the call to eval is a direct call (see 15.1.2.1.1) to the eval function that is contained in strict mode code."

Note "direct call [...] contained in strict mode code". So based on my understanding (and actually, FF4 behavior) this should throw error, but currently doesn't.
Comment 8 Oliver Hunt 2010-10-18 16:42:00 PDT
(In reply to comment #7)
> Hey Oliver.
> 
> I don't have this fresh build yet, but the previous one seems to also fail to set strict mode for eval code (in certain cases). For example:
> 
> (function(){ "use strict"; eval('with({ }) { }') })(); // no error

Was this in the inspector? I'm seeing weird behaviour where code in the inspectors console fails to trigger strict mode
Comment 9 kangax 2010-10-18 16:49:20 PDT
(In reply to comment #8)
> (In reply to comment #7)
> > Hey Oliver.
> > 
> > I don't have this fresh build yet, but the previous one seems to also fail to set strict mode for eval code (in certain cases). For example:
> > 
> > (function(){ "use strict"; eval('with({ }) { }') })(); // no error
> 
> Was this in the inspector? I'm seeing weird behaviour where code in the inspectors console fails to trigger strict mode

Ah. yes it was. Doesn't happen when run from within <script> element. 

Well, then I have nothing else as far as strict mode. Will file bugs if I find anything.
Comment 10 Oliver Hunt 2010-10-18 16:57:32 PDT
(In reply to comment #9)
> (In reply to comment #8)
> > (In reply to comment #7)
> > > Hey Oliver.
> > > 
> > > I don't have this fresh build yet, but the previous one seems to also fail to set strict mode for eval code (in certain cases). For example:
> > > 
> > > (function(){ "use strict"; eval('with({ }) { }') })(); // no error
> > 
> > Was this in the inspector? I'm seeing weird behaviour where code in the inspectors console fails to trigger strict mode
> 
> Ah. yes it was. Doesn't happen when run from within <script> element. 
> 
> Well, then I have nothing else as far as strict mode. Will file bugs if I find anything.

I just landed a fix for the Function constructor which should appear in the next nightly
Comment 11 kangax 2010-10-21 20:08:15 PDT
I think I'm seeing browser crash under strict mode. Filed a separate bug for it — https://bugs.webkit.org/show_bug.cgi?id=48109

Oliver, can you please take a look?
Comment 12 Gavin Barraclough 2011-06-17 00:30:30 PDT
All the strict mode tests pass for me in ToT.