Repository navigation
Remove redundant call to checkNodeDeferred - #22516
2 commits merged into
Conversation
Wesley Wigham (weswigham)
left a comment
There was a problem hiding this comment.
Provided nothing's been obviously broken, it seems fine - I'm pretty sure any context sensitive node that gets checked in SkipContextSensitive will later on be checked in a context-sensitive way and use the following branches which also contain checkNodeDeferred. That these supposedly-one time checks are getting registered during inference (which is inherently multi-pass and shouldn't persist state unless inference succeeds) at all is kinda odd, though. Do we not visit function expressions/object literal methods outside of inference? Given that the grammar checks done in this method which also does inference things, I guess not, but still... odd. It means we recheck the grammar during every every inference pass, which seems wasteful.
I wonder if it wouldn't impact performance to just move all the grammar checking out to its own tree walk -- would certainly make the code easier to read. |
|
Andy (Andrewkraft) (@Andy-MS) We effectively already do js-only grammar checks in a separate tree walk in |
|
|
||
| function registerForUnusedIdentifiersCheck(node: Node) { | ||
| if (deferredUnusedIdentifierNodes) { | ||
| Debug.assert(!contains(deferredUnusedIdentifierNodes, node), "Registering unused identifier twice"); |
There was a problem hiding this comment.
actually, isn't the contains call slow? I imagine the list gets long.
There was a problem hiding this comment.
Yeah contains is a linear search - binarySearch might be a bit better (since the list is probably effectively sorted by node id), but best would just be using a map instead.
Fixes #22491
If I have this right, we will always do one more check after all
SkipContextSensitivechecks.Before this PR, the assertion (also added in this PR) would have failed for most arrow functions in call expressions.
For posterity, a simple test case that failed was:
(we have lots of test cases like this already, so didn't see a need to add a new one.)