Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleEvaluation should return undefined #6272

Merged
merged 1 commit into from Sep 10, 2019

Conversation

rhuanjl
Copy link
Collaborator

@rhuanjl rhuanjl commented Sep 9, 2019

Picking up on discussion in #6266 this reverts an unintended side-effect of #6171

The successful completion value of a module is undefined - this was not tested and the change in #6171 had resulted in it being {done : true} instead.

With this change that is reverted additionally a crude test is added - every time a root module is evaluated in ch the completion value is checked to confirm that it is undefined - this would make every single module test fail if this error was ever re-introduced.

I note the discussion in #6266 was sparked by a desire for the return value to be the result of the last statement in the module - like with a script - this change will not do that as:
a) it seems that was not done before
b) that would be very complex and
c) that is not per specification see https://tc39.es/ecma262/#sec-moduleevaluation

@@ -2022,6 +2022,16 @@ HRESULT WScriptJsrt::ModuleMessage::Call(LPCSTR fileName)
}
}
}
else
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you look into whether it's possible (or makes sense) to add a test case to bin/NativeTests/JsRTApiTest.cpp? I haven't dug around in that file so I'm not sure. If we can and it's not too much work then this probably belongs over there.

Otherwise, I think it would be fine for this PR to just make the change to SourceTextModuleRecord.cpp and we can worry about the test later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

JsRTApiTest doesn't currently test JsModuleEvaluation so it would mean adding a new test to it - that aside I don't really know how that file works so for now I have updated to not have a test and merely revert the unintentional change.

chakrabot pushed a commit that referenced this pull request Sep 10, 2019
Merge pull request #6272 from rhuanjl:moduleReturnUndefined

Picking up on discussion in #6266 this reverts an unintended side-effect of #6171

The successful completion value of a module is `undefined` - this was not tested and the change in #6171 had resulted in it being  `{done : true}` instead.
@chakrabot chakrabot merged commit bcde2bd into chakra-core:master Sep 10, 2019
@rhuanjl rhuanjl deleted the moduleReturnUndefined branch September 10, 2019 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants