10000 Added optimization for slice expression evaluation. It can be skipped… · sourcegraph/scip-python@5fffd5b · GitHub
[go: up one dir, main page]

Skip to content

Commit 5fffd5b

Browse files
committed
Added optimization for slice expression evaluation. It can be skipped in cases where the we are speculatively evaluating the type.
1 parent eeab5b1 commit 5fffd5b

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

packages/pyright-internal/src/analyzer/typeEvaluator.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13002,17 +13002,20 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
1300213002
}
1300313003

1300413004
function getTypeOfSlice(node: SliceNode): TypeResult {
13005-
// Evaluate the expressions to report errors and record symbol references.
13006-
if (node.startValue) {
13007-
getTypeOfExpression(node.startValue);
13008-
}
13005+
// Evaluate the expressions to report errors and record symbol
13006+
// references. We can skip this if we're executing speculatively.
13007+
if (!speculativeTypeTracker.isSpeculative(node)) {
13008+
if (node.startValue) {
13009+
getTypeOfExpression(node.startValue);
13010+
}
1300913011

13010-
if (node.endValue) {
13011-
getTypeOfExpression(node.endValue);
13012-
}
13012+
if (node.endValue) {
13013+
getTypeOfExpression(node.endValue);
13014+
}
1301313015

13014-
if (node.stepValue) {
13015-
getTypeOfExpression(node.stepValue);
13016+
if (node.stepValue) {
13017+
getTypeOfExpression(node.stepValue);
13018+
}
1301613019
}
1301713020

1301813021
return { type: getBuiltInObject(node, 'slice'), node };

0 commit comments

Comments
 (0)
0