@zzzen/pyright-internal 1.2.0-dev.20241103 → 1.2.0-dev.20241117
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analyzer/binder.d.ts +1 -0
- package/dist/analyzer/binder.js +35 -12
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.js +2 -2
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/dataClasses.js +0 -4
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/importResolver.d.ts +1 -1
- package/dist/analyzer/importResolver.js +5 -5
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/operations.js +6 -0
- package/dist/analyzer/operations.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.js +6 -3
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/patternMatching.js +3 -1
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/service.js +3 -3
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/serviceUtils.d.ts +0 -2
- package/dist/analyzer/serviceUtils.js +3 -5
- package/dist/analyzer/serviceUtils.js.map +1 -1
- package/dist/analyzer/symbol.js +1 -1
- package/dist/analyzer/symbol.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +216 -155
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +19 -1
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.js +9 -7
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typeUtils.js +10 -8
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/common/asyncInitialization.d.ts +1 -0
- package/dist/common/asyncInitialization.js +20 -0
- package/dist/common/asyncInitialization.js.map +1 -0
- package/dist/common/pathConsts.d.ts +3 -0
- package/dist/common/pathConsts.js +4 -1
- package/dist/common/pathConsts.js.map +1 -1
- package/dist/common/tomlUtils.d.ts +6 -0
- package/dist/common/tomlUtils.js +28 -0
- package/dist/common/tomlUtils.js.map +1 -0
- package/dist/languageService/autoImporter.d.ts +6 -2
- package/dist/languageService/autoImporter.js +15 -15
- package/dist/languageService/autoImporter.js.map +1 -1
- package/dist/languageService/completionProvider.js +3 -1
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/fileWatcherDynamicFeature.js +2 -2
- package/dist/languageService/fileWatcherDynamicFeature.js.map +1 -1
- package/dist/languageService/signatureHelpProvider.js +21 -13
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +5 -4
- package/dist/localization/localize.js +5 -2
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +1 -2
- package/dist/localization/package.nls.de.json +2 -3
- package/dist/localization/package.nls.en-us.json +19 -4
- package/dist/localization/package.nls.es.json +2 -3
- package/dist/localization/package.nls.fr.json +1 -2
- package/dist/localization/package.nls.it.json +2 -3
- package/dist/localization/package.nls.ja.json +1 -2
- package/dist/localization/package.nls.ko.json +1 -2
- package/dist/localization/package.nls.pl.json +1 -2
- package/dist/localization/package.nls.pt-br.json +1 -2
- package/dist/localization/package.nls.qps-ploc.json +1 -2
- package/dist/localization/package.nls.ru.json +1 -2
- package/dist/localization/package.nls.tr.json +1 -2
- package/dist/localization/package.nls.zh-cn.json +1 -2
- package/dist/localization/package.nls.zh-tw.json +1 -2
- package/dist/nodeMain.d.ts +1 -1
- package/dist/nodeMain.js +2 -2
- package/dist/nodeMain.js.map +1 -1
- package/dist/nodeServer.d.ts +1 -1
- package/dist/nodeServer.js +3 -5
- package/dist/nodeServer.js.map +1 -1
- package/dist/parser/parseNodes.d.ts +3 -2
- package/dist/parser/parseNodes.js +2 -1
- package/dist/parser/parseNodes.js.map +1 -1
- package/dist/parser/parser.d.ts +2 -1
- package/dist/parser/parser.js +36 -7
- package/dist/parser/parser.js.map +1 -1
- package/dist/pyright.js +2 -4
- package/dist/pyright.js.map +1 -1
- package/dist/tests/fourslash/signature.dataclassAlias.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/signature.dataclassAlias.fourslash.js +73 -0
- package/dist/tests/fourslash/signature.dataclassAlias.fourslash.js.map +1 -0
- package/dist/tests/harness/fourslash/testState.js +14 -1
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/fourslash/testStateUtils.js +2 -2
- package/dist/tests/harness/fourslash/testStateUtils.js.map +1 -1
- package/dist/tests/lsp/languageServer.d.ts +1 -1
- package/dist/tests/lsp/languageServer.js +3 -1
- package/dist/tests/lsp/languageServer.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +1 -1
- package/dist/tests/typeEvaluator3.test.js +5 -1
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +1 -1
- package/dist/tests/typeEvaluator5.test.js +2 -2
- package/dist/tests/typeEvaluator6.test.js +11 -1
- package/dist/tests/typeEvaluator6.test.js.map +1 -1
- package/dist/tests/typeEvaluator7.test.js +3 -3
- package/dist/tests/typeEvaluator7.test.js.map +1 -1
- package/package.json +2 -2
package/dist/parser/parser.js
CHANGED
@@ -77,7 +77,7 @@ class Parser {
|
|
77
77
|
this._diagSink = new diagnosticSink_1.DiagnosticSink();
|
78
78
|
this._isInLoop = false;
|
79
79
|
this._isInFunction = false;
|
80
|
-
this.
|
80
|
+
this._isInExceptionGroup = false;
|
81
81
|
this._isParsingTypeAnnotation = false;
|
82
82
|
this._isParsingIndexTrailer = false;
|
83
83
|
this._isParsingQuotedText = false;
|
@@ -1045,11 +1045,18 @@ class Parser {
|
|
1045
1045
|
}
|
1046
1046
|
return ifNode;
|
1047
1047
|
}
|
1048
|
+
_parseExceptSuite(isExceptionGroup, callback) {
|
1049
|
+
const wasInExceptionGroup = this._isInExceptionGroup;
|
1050
|
+
if (isExceptionGroup) {
|
1051
|
+
this._isInExceptionGroup = true;
|
1052
|
+
}
|
1053
|
+
const result = callback();
|
1054
|
+
this._isInExceptionGroup = wasInExceptionGroup;
|
1055
|
+
return result;
|
1056
|
+
}
|
1048
1057
|
_parseLoopSuite() {
|
1049
1058
|
const wasInLoop = this._isInLoop;
|
1050
|
-
const wasInFinally = this._isInFinally;
|
1051
1059
|
this._isInLoop = true;
|
1052
|
-
this._isInFinally = false;
|
1053
1060
|
let typeComment;
|
1054
1061
|
const suite = this._parseSuite(this._isInFunction, /* skipBody */ false, () => {
|
1055
1062
|
const comment = this._getTypeAnnotationCommentText();
|
@@ -1058,7 +1065,6 @@ class Parser {
|
|
1058
1065
|
}
|
1059
1066
|
});
|
1060
1067
|
this._isInLoop = wasInLoop;
|
1061
|
-
this._isInFinally = wasInFinally;
|
1062
1068
|
if (typeComment) {
|
1063
1069
|
suite.d.typeComment = typeComment;
|
1064
1070
|
}
|
@@ -1354,6 +1360,7 @@ class Parser {
|
|
1354
1360
|
const trySuite = this._parseSuite(this._isInFunction);
|
1355
1361
|
const tryNode = parseNodes_1.TryNode.create(tryToken, trySuite);
|
1356
1362
|
let sawCatchAllExcept = false;
|
1363
|
+
let reportedExceptGroupMismatch = false;
|
1357
1364
|
while (true) {
|
1358
1365
|
const exceptToken = this._peekToken();
|
1359
1366
|
if (!this._consumeTokenIfKeyword(14 /* KeywordType.Except */)) {
|
@@ -1368,6 +1375,16 @@ class Parser {
|
|
1368
1375
|
this._addSyntaxError(localize_1.LocMessage.exceptionGroupIncompatible(), possibleStarToken);
|
1369
1376
|
}
|
1370
1377
|
isExceptGroup = true;
|
1378
|
+
if (!reportedExceptGroupMismatch && tryNode.d.exceptClauses.some((clause) => !clause.d.isExceptGroup)) {
|
1379
|
+
this._addSyntaxError(localize_1.LocMessage.exceptGroupMismatch(), possibleStarToken);
|
1380
|
+
reportedExceptGroupMismatch = true;
|
1381
|
+
}
|
1382
|
+
}
|
1383
|
+
else {
|
1384
|
+
if (!reportedExceptGroupMismatch && tryNode.d.exceptClauses.some((clause) => clause.d.isExceptGroup)) {
|
1385
|
+
this._addSyntaxError(localize_1.LocMessage.exceptGroupMismatch(), possibleStarToken);
|
1386
|
+
reportedExceptGroupMismatch = true;
|
1387
|
+
}
|
1371
1388
|
}
|
1372
1389
|
let typeExpr;
|
1373
1390
|
let symbolName;
|
@@ -1389,6 +1406,9 @@ class Parser {
|
|
1389
1406
|
}
|
1390
1407
|
}
|
1391
1408
|
}
|
1409
|
+
else if (isExceptGroup) {
|
1410
|
+
this._addSyntaxError(localize_1.LocMessage.exceptGroupRequiresType(), this._peekToken());
|
1411
|
+
}
|
1392
1412
|
if (!typeExpr) {
|
1393
1413
|
if (sawCatchAllExcept) {
|
1394
1414
|
this._addSyntaxError(localize_1.LocMessage.duplicateCatchAll(), exceptToken);
|
@@ -1400,7 +1420,7 @@ class Parser {
|
|
1400
1420
|
this._addSyntaxError(localize_1.LocMessage.namedExceptAfterCatchAll(), typeExpr);
|
1401
1421
|
}
|
1402
1422
|
}
|
1403
|
-
const exceptSuite = this._parseSuite(this._isInFunction);
|
1423
|
+
const exceptSuite = this._parseExceptSuite(isExceptGroup, () => this._parseSuite(this._isInFunction));
|
1404
1424
|
const exceptNode = parseNodes_1.ExceptNode.create(exceptToken, exceptSuite, isExceptGroup);
|
1405
1425
|
if (typeExpr) {
|
1406
1426
|
exceptNode.d.typeExpr = typeExpr;
|
@@ -1464,11 +1484,14 @@ class Parser {
|
|
1464
1484
|
returnType = this._parseTypeAnnotation();
|
1465
1485
|
}
|
1466
1486
|
let functionTypeAnnotationToken;
|
1487
|
+
const wasInExceptionGroup = this._isInExceptionGroup;
|
1488
|
+
this._isInExceptionGroup = false;
|
1467
1489
|
const suite = this._parseSuite(/* isFunction */ true, this._parseOptions.skipFunctionAndClassBody, () => {
|
1468
1490
|
if (!functionTypeAnnotationToken) {
|
1469
1491
|
functionTypeAnnotationToken = this._getTypeAnnotationCommentText();
|
1470
1492
|
}
|
1471
1493
|
});
|
1494
|
+
this._isInExceptionGroup = wasInExceptionGroup;
|
1472
1495
|
const functionNode = parseNodes_1.FunctionNode.create(defToken, parseNodes_1.NameNode.create(nameToken), suite, typeParameters);
|
1473
1496
|
if (asyncToken) {
|
1474
1497
|
functionNode.d.isAsync = true;
|
@@ -1900,6 +1923,9 @@ class Parser {
|
|
1900
1923
|
if (!this._isInLoop) {
|
1901
1924
|
this._addSyntaxError(localize_1.LocMessage.breakOutsideLoop(), breakToken);
|
1902
1925
|
}
|
1926
|
+
else if (this._isInExceptionGroup) {
|
1927
|
+
this._addSyntaxError(localize_1.LocMessage.breakInExceptionGroup(), breakToken);
|
1928
|
+
}
|
1903
1929
|
return parseNodes_1.BreakNode.create(breakToken);
|
1904
1930
|
}
|
1905
1931
|
_parseContinueStatement() {
|
@@ -1907,8 +1933,8 @@ class Parser {
|
|
1907
1933
|
if (!this._isInLoop) {
|
1908
1934
|
this._addSyntaxError(localize_1.LocMessage.continueOutsideLoop(), continueToken);
|
1909
1935
|
}
|
1910
|
-
else if (this.
|
1911
|
-
this._addSyntaxError(localize_1.LocMessage.
|
1936
|
+
else if (this._isInExceptionGroup) {
|
1937
|
+
this._addSyntaxError(localize_1.LocMessage.continueInExceptionGroup(), continueToken);
|
1912
1938
|
}
|
1913
1939
|
return parseNodes_1.ContinueNode.create(continueToken);
|
1914
1940
|
}
|
@@ -1919,6 +1945,9 @@ class Parser {
|
|
1919
1945
|
if (!this._isInFunction) {
|
1920
1946
|
this._addSyntaxError(localize_1.LocMessage.returnOutsideFunction(), returnToken);
|
1921
1947
|
}
|
1948
|
+
else if (this._isInExceptionGroup) {
|
1949
|
+
this._addSyntaxError(localize_1.LocMessage.returnInExceptionGroup(), returnToken);
|
1950
|
+
}
|
1922
1951
|
if (!this._isNextTokenNeverExpression()) {
|
1923
1952
|
const returnExpr = this._parseTestOrStarListAsExpression(
|
1924
1953
|
/* allowAssignmentExpression */ true,
|