-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1.8>1.9] [MERGE #4673 @boingoing] OS#14115684: Function-in-block sem…
…antics don't work for defer parse Merge pull request #4673 from boingoing:DeferFunctionInBlock In below code repro, we do not create var decl binding for `foo` inside the `nest` function in defer-parse mode. Due to this, we leave the reference to `foo` in `nest` on the pid ref stack and bind it to the formal `foo` parameter from the `test` function. This leads us to think formal `foo` is captured and try to put it into a scope slot. However, formal `foo` is not actually captured so no scope slot is allocated. When we actually generate bytecode for `test`, we hit a fail fast. ```js function test(foo) { function nest() { { function foo() { console.log('pass'); } } foo(); } nest(); } test(()=>console.log('fail')); ``` Fix is to create the var binding for `foo` at the function declaration for `foo` even in defer-parse mode. Fixes: https://microsoft.visualstudio.com/web/wi.aspx?id=14115684
- Loading branch information
Showing
4 changed files
with
43 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//------------------------------------------------------------------------------------------------------- | ||
// Copyright (C) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information. | ||
//------------------------------------------------------------------------------------------------------- | ||
|
||
function test(foo) { | ||
function nest() { | ||
{ | ||
function foo() { | ||
console.log('pass'); | ||
} | ||
} | ||
foo(); | ||
} | ||
nest(); | ||
} | ||
test(()=>console.log('fail')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters