[Webkit-unassigned] [Bug 163208] [ES6]. Implement Annex B.3.3 function hoisting rules for eval

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Feb 13 11:42:18 PST 2017


https://bugs.webkit.org/show_bug.cgi?id=163208

--- Comment #48 from GSkachkov <gskachkov at gmail.com> ---
Comment on attachment 301300
  --> https://bugs.webkit.org/attachment.cgi?id=301300
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=301300&action=review

>> Source/JavaScriptCore/ChangeLog:24
>> +        has var type we bind function there
> 
> This code I believe is slightly wrong w.r.t the specification.
> The behavior we want is not to always create the binding and then to conditionally bind, but rather, to conditionally create the binding, and to bind to it unconditionally if we created it.
> 
> For example, I checked out your code, and this function won't throw an exception. It'll return undefined. I believe the desired behavior is to throw a ReferenceError:
> 
> ```
> function foo() {
>     {
>         let f;
>         eval("{ function f() { return 20; } }");
>     }
>     return f;
> }
> foo();
> ```
> 
> That said, I think this patch still does the majority of the work to implementing what I said above. To get the behavior I said above, I think all you'll need to do is change code inside Interpreter.cpp when running eval code.
> I think it's best at this point to do this fix as a follow up.

Yeah, my bad, I see my patch is only focus to conditionally bind.

>> Source/JavaScriptCore/runtime/JSScope.cpp:248
>> +            continue;
> 
> What does the spec say here? Does it say to skip over `with`? Or does it say to iterate the scope chain during `eval` instantiation.
> This is important because the hasProperty below is observable for `with` scopes.
> 
> Also, thinking about this patch more, I think the resolve_closest_or_var and is_var_scope_type could be fully answerable during bytecode linking if the spec behavior is to skip over `with` scopes.
> So we need to find out if we indeed skip `with` scopes, or we somehow interact with them when creating the eval.

According to spec B.3.3.3.1.d.ii.4 we do loop over EnvironmentRecord, and  only B.3.3.3.1.d.ii.4.b we do check 'If thisEnvRec is not an _object_ Environment Record'
and then in B.3.3.3.1.d.ii.4.b.i we do check hasBinding for found object. So how I can understand we need to skip 'with' scope

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20170213/b93ac83d/attachment.html>


More information about the webkit-unassigned mailing list