Bug 64424

Summary: Our direct eval behaviour deviates slightly from the spec.
Product: WebKit Reporter: Gavin Barraclough <barraclough>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: dglazkov, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
The patch
oliver: review+, webkit.review.bot: commit-queue-
Archive of layout-test-results from ec2-cr-linux-01 none

Description Gavin Barraclough 2011-07-12 19:29:16 PDT
The ES5 spec defines a concept of 'Direct Call to Eval' (see section 15.1.2.1.1), where behaviour will differ from that of an indirect call (e.g. " { eval: window.eval }.eval();" or "var a = eval; a();" are indirect calls), particularly in non-strict scopes variables may be introduced into the caller's environment.

ES5 direct calls are any call where the callee function is provided by a reference, a base of that Reference is an EnvironmentRecord (this corresponds to all productions "PrimaryExpression: Identifier", see 10.2.2.1 GetIdentifierReference), and where the name of the reference is "eval".  This means any expression of the form "eval(...)", and that calls the standard built in eval method from on the Global Object, is considered to be direct.

In JavaScriptCore we are currently overly restrictive.  We also check that the EnvironmentRecord that is the base of the reference is the Declaractive Environment Record at the root of the scope chain, corresponding to the Global Object - an "eval(..)" statement that hits a var eval in a nested scope is not considered to be direct.  This behaviour does not emanate from the spec, and is incorrect.
Comment 1 Gavin Barraclough 2011-07-12 23:09:32 PDT
Created attachment 100631 [details]
The patch
Comment 2 WebKit Review Bot 2011-07-12 23:37:00 PDT
Comment on attachment 100631 [details]
The patch

Attachment 100631 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/9016454

New failing tests:
fast/js/eval-keyword-vs-function.html
Comment 3 WebKit Review Bot 2011-07-12 23:37:06 PDT
Created attachment 100634 [details]
Archive of layout-test-results from ec2-cr-linux-01

The attached test failures were seen while running run-webkit-tests on the chromium-ews.
Bot: ec2-cr-linux-01  Port: Chromium  Platform: Linux-2.6.35-28-virtual-x86_64-with-Ubuntu-10.10-maverick
Comment 4 Gavin Barraclough 2011-07-13 12:02:19 PDT
Fixed in r90938