-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Reuse operandType in checkPrefixUnaryExpression #53682
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
Reuse operandType in checkPrefixUnaryExpression #53682
Conversation
@typescript-bot perf test this |
Heya @jakebailey, I've started to run the perf test suite on this PR at 7fa4ac5. You can monitor the build here. Update: The results are in! |
@jakebailey Here they are:
CompilerComparison Report - main..53682
System
Hosts
Scenarios
TSServerComparison Report - main..53682
System
Hosts
Scenarios
StartupComparison Report - main..53682
System
Hosts
Scenarios
Developer Information: |
Seems like no change. Let's test the rest. @typescript-bot test this |
Heya @jakebailey, I've started to run the diff-based user code test suite (tsserver) on this PR at 7fa4ac5. You can monitor the build here. Update: The results are in! |
Heya @jakebailey, I've started to run the diff-based top-repos suite on this PR at 7fa4ac5. You can monitor the build here. Update: The results are in! |
Heya @jakebailey, I've started to run the diff-based top-repos suite (tsserver) on this PR at 7fa4ac5. You can monitor the build here. Update: The results are in! |
Heya @jakebailey, I've started to run the diff-based user code test suite on this PR at 7fa4ac5. You can monitor the build here. Update: The results are in! |
Heya @jakebailey, I've started to run the parallelized Definitely Typed test suite on this PR at 7fa4ac5. You can monitor the build here. Update: The results are in! |
Heya @jakebailey, I've started to run the extended test suite on this PR at 7fa4ac5. You can monitor the build here. |
@jakebailey Here are the results of running the user test suite comparing There were infrastructure failures potentially unrelated to your change:
Otherwise... Everything looks good! |
@jakebailey Here are the results of running the user test suite comparing Everything looks good! |
@jakebailey Here are the results of running the top-repos suite comparing Everything looks good! |
Hey @jakebailey, the results of running the DT tests are ready. |
@jakebailey Here are the results of running the top-repos suite comparing Everything looks good! |
==== tests/cases/compiler/nestedUnaryExpressionHang.ts (2 errors) ==== | ||
3333%!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. |
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.
This code doesn't parse properly, but, that's the test case that the fuzzer gave me so I feel like it's fine? But, I can try and come up with something that exhibits this problem without errors if desired.
@@ -36120,7 +36120,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { | |||
} | |||
return getUnaryResultType(operandType); | |||
case SyntaxKind.ExclamationToken: | |||
checkTruthinessExpression(node.operand); | |||
checkTruthinessOfType(operandType, node.operand); |
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.
This direct call to checkTruthinessOfType
when the operand type is known mirrors our handling of binary expressions in onOperator
.
I checked all other call sites, and only this one benefits from not reevaluating the type (which is good, unless we wanted to find more of these for even more perf!).
This was caught by jazzer as a timeout.
This code wasn't reusing
operandType
, so it was duplicating the check. If we nest this, this means that we're doing 2^n checks!The test case here normally times out (and totally freezes tsserver; don't open it), but now finishes pretty much instantly.