-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
JS: New query: missing await #2525
JS: New query: missing await #2525
Conversation
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.
Nice idea! A few initial thoughts.
Co-Authored-By: Erik Krogh Kristensen <erik-krogh@github.com>
Co-Authored-By: Max Schaefer <54907921+max-schaefer@users.noreply.github.com>
Evaluation looks ok - there is a slight cost of the change to |
@mchammer01: apologies, I merged this without realising that you hadn't reviewed the query help yet. The preview is still available here. |
I'll take a look when I can (have been having back-to-back meetings all week and wasn't in yesterday). |
@asgerf - this LGTM but you need to add this new query to the change-notes/1.24/analysis-javascript.md file. |
Adds a query to flag cases where a promise was used, but where the intention most likely to use the result of the promise instead.
Null checks are particularly interesting here.
async
functions never returnnull
, and so a null check will silently fail.We use the call graph and static types to recognize promises, although I'm not sure how much use we get from the static types are here, as we probably only flag what the type checker would have flagged anyway. As seen here it gets noisy if we assume something of a promise type is non-nullable, so we can't use them to flag null checks.
Contains a drive-by change to
getImmediatePredecessor
to make it step through phi nodes whose operands are all refinements of the same value. I couldn't resist calling such nodes rephinement nodes.Still need to run an evaluation, especially of the second commit.