8000 Fixed bug in the expression printer. It was not properly handling a m… · sourcegraph/scip-python@eeab5b1 · GitHub
[go: up one dir, main page]

Skip to content

Commit eeab5b1

Browse files
committed
Fixed bug in the expression printer. It was not properly handling a minimal slice (:).
1 parent 8bc14ef commit eeab5b1

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -371,15 +371,21 @@ export function printExpression(node: ExpressionNode, flags = PrintExpressionFla
371371

372372
case ParseNodeType.Slice: {
373373
let result = '';
374-
if (node.startValue) {
375-
result += printExpression(node.startValue, flags);
376-
}
377-
if (node.endValue) {
378-
result += ': ' + printExpression(node.endValue, flags);
379-
}
380-
if (node.stepValue) {
381-
result += ': ' + printExpression(node.stepValue, flags);
374+
375+
if (node.startValue || node.endValue || node.stepValue) {
376+
if (node.startValue) {
377+
result += printExpression(node.startValue, flags);
378+
}
379+
if (node.endValue) {
380+
result += ': ' + printExpression(node.endValue, flags);
381+
}
382+
if (node.stepValue) {
383+
result += ': ' + printExpression(node.stepValue, flags);
384+
}
385+
} else {
386+
result += ':';
382387
}
388+
383389
return result;
384390
}
385391

0 commit comments

Comments
 (0)
0