Added optimization for slice expression evaluation. It can be skipped in cases where the we are speculatively evaluating the type.

This commit is contained in:
Eric Traut 2022-07-04 21:39:42 -07:00
parent eeab5b127c
commit 5fffd5bbcf

View File

@ -13002,17 +13002,20 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
}
function getTypeOfSlice(node: SliceNode): TypeResult {
// Evaluate the expressions to report errors and record symbol references.
if (node.startValue) {
getTypeOfExpression(node.startValue);
}
// Evaluate the expressions to report errors and record symbol
// references. We can skip this if we're executing speculatively.
if (!speculativeTypeTracker.isSpeculative(node)) {
if (node.startValue) {
getTypeOfExpression(node.startValue);
}
if (node.endValue) {
getTypeOfExpression(node.endValue);
}
if (node.endValue) {
getTypeOfExpression(node.endValue);
}
if (node.stepValue) {
getTypeOfExpression(node.stepValue);
if (node.stepValue) {
getTypeOfExpression(node.stepValue);
}
}
return { type: getBuiltInObject(node, 'slice'), node };