Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Fix additional function mutable binding function scope #1291

Closed
wants to merge 1 commit into from

Conversation

jeffreytan81
Copy link
Contributor

@jeffreytan81 jeffreytan81 commented Dec 21, 2017

Release Note: none

Fix #1238
The behavior of the bug is that, get_scope_binding() helper function is generated in wrong scope: global scope instead of additional function scope.
It happens because there are two scopes referencing it, additional function itself and its parent generator scope. The second one is problematic because "obj" is not referenced in parent generator scope. We should visitPropertiesAndBindings only from additional function scope itself instead of parent generator scope.

[The changes in react compiler]: with above change, all the hoistable react elements will be in additional function's parent generator scope so align the change in the react/hoisting.js file.

@jeffreytan81
Copy link
Contributor Author

@trueadm, only react tests failed for this. Is there any wiki talking about how to best debug single react test failure? I can try investigate the react test runner, but it would be time saving if there is a documentation for it.

@trueadm
Copy link
Contributor

trueadm commented Dec 22, 2017

@yinghuitan Might be worth pining @cblappert as I helped him yesterday set up a debug environment for the React test cases.

What I do, is setup a local file and run it via the CLI with the Node debugger enabled. You'll need to enable reactEnabled, set the compatibility flag to react-mocks and the reactOutput flag to either jsx or create-element, depending on which one failed for you. I'll write this all up in the wiki after the holiday season :)

@@ -729,11 +729,12 @@ export class ResidualHeapVisitor {
instance: funcInstance,
});
this.visitGenerator(generator);
this._withScope(generator, visitPropertiesAndBindings);
// All modified properties and bindings should be accessible
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment sounds reasonable. Should the visitGenerator call one line earlier also get the same treatment? If not, why not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not, "generator" above represents any time sensitive generator entries captured in the additional function so it should be visited from that generator(or its sub-generators).
While for modified properties and bindings that are not captured in generator, they should be in additional function's scope(the change here).

Copy link
Contributor

@NTillmann NTillmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yinghuitan is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@hermanventer hermanventer deleted the FixAdditionalFunctionScopeBug branch January 1, 2018 19:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants