OS#14115684: Function-in-block semantics don't work for defer parse - #4673
Merged
chakrabot merged 1 commit intoFeb 13, 2018
Merged
Conversation
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
boingoing
force-pushed
the
DeferFunctionInBlock
branch
from
February 13, 2018 01:23
8345462 to
c3d4e4d
Compare
Contributor
Author
|
@dotnet-bot test OSX static_osx_osx_debug please |
pleath
approved these changes
Feb 13, 2018
Contributor
Author
|
Thanks, Paul. |
chakrabot
pushed a commit
that referenced
this pull request
Feb 13, 2018
…'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
chakrabot
pushed a commit
that referenced
this pull request
Feb 13, 2018
…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
chakrabot
pushed a commit
that referenced
this pull request
Feb 13, 2018
…-in-block semantics 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
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In below code repro, we do not create var decl binding for
fooinside thenestfunction in defer-parse mode. Due to this, we leave the reference tofooinneston the pid ref stack and bind it to the formalfooparameter from thetestfunction. This leads us to think formalfoois captured and try to put it into a scope slot. However, formalfoois not actually captured so no scope slot is allocated. When we actually generate bytecode fortest, we hit a fail fast.Fix is to create the var binding for
fooat the function declaration forfooeven in defer-parse mode.Fixes:
https://microsoft.visualstudio.com/web/wi.aspx?id=14115684