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

Invalid argument error of __evaluatePureFunction function is changed to CompilerDiagnostics Error #2403

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rahilvora
Copy link

@rahilvora rahilvora commented Aug 9, 2018

Release Note: invalid argument error of __evaluatePureFunction function is changed from InvariantError to CompilerDiagnostics Error

Fixes #2385

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@trueadm
Copy link
Contributor

trueadm commented Aug 9, 2018

@rahilvora Thanks for looking into this. You have a Flow error in your PR, if you can check? Seems that you are using CompilerDiagnostic without the right number of arguments.

@rahilvora
Copy link
Author

@trueadm Sure.

invariant(functionValue instanceof ECMAScriptSourceFunctionValue);
invariant(typeof functionValue.$Call === "function");
if (!(functionValue instanceof ECMAScriptSourceFunctionValue) || typeof functionValue.$Call !== "function") {
let error = new CompilerDiagnostic("CompilerDiagnostic Error");
Copy link
Contributor

Choose a reason for hiding this comment

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

Please have a look at other places where CompilerDiagnostic instances are created. There are niceties to be observed and you should not throw diagnostics.

@rahilvora rahilvora force-pushed the evaluatePureFunction_does_not_properly_validate_agrs_fix branch 2 times, most recently from 0a5729c to 9df1a08 Compare August 10, 2018 22:33
);
} else {
realm.handleError(
new CompilerDiagnostic(`CompilerDiagnostic Error`, realm.currentLocation, "PP1005", "Warning")
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is a warning, it is recoverable and you should throw the fatal error only if the return result of handleError is "Fail".

Copy link
Author

Choose a reason for hiding this comment

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

I believe it should not be a warning but an error as bug says

'In the implementation, it shouldn't check via an invariant that the argument is a proper value, but instead, it should throw a user-level exception or emit a CompilerDiagnostics error.'

Should I replace warning with error?

Copy link
Contributor

Choose a reason for hiding this comment

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

In that case then yes, "FatalError" not "Warning". And then don't recover.

@rahilvora rahilvora force-pushed the evaluatePureFunction_does_not_properly_validate_agrs_fix branch from 9df1a08 to 46c30a1 Compare August 12, 2018 01:25
@hermanventer hermanventer changed the title Release Note: invalid argument error of __evaluatePureFunction function is changed from InvariantError to CompilerDiagnostics Error Invalid argument error of __evaluatePureFunction function is changed to CompilerDiagnostics Error Aug 12, 2018
…on is changed from InvariantError to CompilerDiagnostics Error
@rahilvora rahilvora force-pushed the evaluatePureFunction_does_not_properly_validate_agrs_fix branch from 46c30a1 to 0aea110 Compare August 12, 2018 05:16
);
} else {
realm.handleError(
new CompilerDiagnostic(`CompilerDiagnostic Error`, realm.currentLocation, "PP1005", "FatalError")
Copy link
Contributor

Choose a reason for hiding this comment

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

We need an error message that will help a developer pin point what is wrong and help them understand how to fix it. The error code needs to be unique and there should be a wiki page that documents the error in some detail, preferably along with example code.

@hermanventer hermanventer added help wanted stale A pull request that is not ready for landing and has not been worked on for at least a week labels Oct 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA Signed help wanted stale A pull request that is not ready for landing and has not been worked on for at least a week
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants