[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
Tue Apr 4 13:26:14 PDT 2017


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

--- Comment #64 from Saam Barati <sbarati at apple.com> ---
Comment on attachment 304941
  --> https://bugs.webkit.org/attachment.cgi?id=304941
Patch

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

> Source/JavaScriptCore/interpreter/Interpreter.cpp:1094
> +    int numTopLevelFunctionDecls = eval->numTopLevelFunctionDecls();

I know this is how the code was before, but let's make this function return an unsigned integer. It's dumb that this is a signed int.

>>> Source/JavaScriptCore/interpreter/Interpreter.cpp:1095
>>> +    unsigned numCodeBlockFunctionDecls = eval->numCodeBlockFunctionDecls();
>> 
>> These names are not better IMO.
>> 
>> I still don't understand what the difference here is. Can you explain this to me with an example?
> 
> As I remember spec, top level function in eval might lead to error of redeclaration. 
> ```
> function bar() {
>     {
>         let f = 20;
>         let value = 10; 
>         eval("function f() { value = 20; }; f();");
>         print(value);
>     }
> }
> bar(); // SyntaxError: Can't create duplicate variable in eval: 'f'
> ``` 
> 
> but function declared in code block not lead to error
> ```
> function baz() {
>     {
>         let f = 20;
>         let value = 10; 
>         eval("{ function f() { value = 20; }; f();}");
>         print(value);
>     }
> }
> baz(); // 20
> ``` 
> So we need to differentiate them.

Ok. I understand what's going on now.
I like the name top level function. For the "CodeBlockFunctions", I'll propose a different name: "functionHoistingCandidates" or something similar.
This is more in line with our terminology elsewhere.

-- 
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/20170404/6476c124/attachment.html>


More information about the webkit-unassigned mailing list