WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
152844
ES6: Implement lexical scoping for function definitions in strict mode
https://bugs.webkit.org/show_bug.cgi?id=152844
Summary
ES6: Implement lexical scoping for function definitions in strict mode
Saam Barati
Reported
2016-01-07 12:19:57 PST
The current flavor of programs break because of function hoisting: ``` let cond = true if (cond) { let h = 20; function bar() { return h; // ReferenceError because bar is hoisted outside of "if" statement scope } baz(); } ```
Attachments
WIP
(49.88 KB, patch)
2016-03-08 19:40 PST
,
Saam Barati
no flags
Details
Formatted Diff
Diff
patch
(80.62 KB, patch)
2016-03-09 14:30 PST
,
Saam Barati
ggaren
: review+
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Saam Barati
Comment 1
2016-03-07 19:08:51 PST
Lets start with just implementing this in strict mode. Then I think there is some algorithm defined in the spec where where we can make the example listed here work as long as we don't break backwards compatibility.
Saam Barati
Comment 2
2016-03-08 19:40:20 PST
Created
attachment 273374
[details]
WIP I think most of the code is done. Just need to write new tests and edit old tests.
Saam Barati
Comment 3
2016-03-09 14:30:56 PST
Created
attachment 273480
[details]
patch
WebKit Commit Bot
Comment 4
2016-03-09 14:33:36 PST
Attachment 273480
[details]
did not pass style-queue: ERROR: Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:1886: Missing space before { [whitespace/braces] [5] Total errors found: 1 in 17 files If any of these errors are false positives, please file a bug against check-webkit-style.
Geoffrey Garen
Comment 5
2016-03-09 14:36:46 PST
Comment on
attachment 273480
[details]
patch View in context:
https://bugs.webkit.org/attachment.cgi?id=273480&action=review
r=me
> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:1897 > + * We can transform block scoped function declarations in strict mode like so:
This is more like a must than a can.
> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:2638 > + HashSet<UniquedStringImpl*> functionsToRemove;
This should be a Vector with inline capacity.
Saam Barati
Comment 6
2016-03-09 14:51:40 PST
Comment on
attachment 273480
[details]
patch View in context:
https://bugs.webkit.org/attachment.cgi?id=273480&action=review
>> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:1897 >> + * We can transform block scoped function declarations in strict mode like so: > > This is more like a must than a can.
Indeed. Will change.
>> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:2638 >> + HashSet<UniquedStringImpl*> functionsToRemove; > > This should be a Vector with inline capacity.
Yeah of course. I don't know why I thought there could be duplicates.
Saam Barati
Comment 7
2016-03-09 18:04:25 PST
landed in:
http://trac.webkit.org/changeset/197915
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug