-
Notifications
You must be signed in to change notification settings - Fork 422
Invalid argument error of __evaluatePureFunction function is changed to CompilerDiagnostics Error #2403
base: main
Are you sure you want to change the base?
Conversation
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! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
@rahilvora Thanks for looking into this. You have a Flow error in your PR, if you can check? Seems that you are using |
@trueadm Sure. |
src/intrinsics/prepack/global.js
Outdated
invariant(functionValue instanceof ECMAScriptSourceFunctionValue); | ||
invariant(typeof functionValue.$Call === "function"); | ||
if (!(functionValue instanceof ECMAScriptSourceFunctionValue) || typeof functionValue.$Call !== "function") { | ||
let error = new CompilerDiagnostic("CompilerDiagnostic Error"); |
There was a problem hiding this comment.
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.
0a5729c
to
9df1a08
Compare
src/intrinsics/prepack/global.js
Outdated
); | ||
} else { | ||
realm.handleError( | ||
new CompilerDiagnostic(`CompilerDiagnostic Error`, realm.currentLocation, "PP1005", "Warning") |
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
9df1a08
to
46c30a1
Compare
…on is changed from InvariantError to CompilerDiagnostics Error
46c30a1
to
0aea110
Compare
); | ||
} else { | ||
realm.handleError( | ||
new CompilerDiagnostic(`CompilerDiagnostic Error`, realm.currentLocation, "PP1005", "FatalError") |
There was a problem hiding this comment.
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.
Release Note: invalid argument error of __evaluatePureFunction function is changed from InvariantError to CompilerDiagnostics Error
Fixes #2385