Skip to content

Commit

Permalink
Fixes Internal error with type statement. #PyDev-1267
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Feb 7, 2025
1 parent 22b16a0 commit 3f7e1f2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,16 @@ public final SimpleNode onCloseNode(SimpleNode n, int arity) throws Exception {

type_params_suiteType t = null;
if (arity >= 2) {
t = (type_params_suiteType) stack.popNode();
final SimpleNode node = stack.popNode();
if (defaultValue == null && (node instanceof exprType)) {
defaultValue = (exprType) node;
} else {
if (node instanceof type_params_suiteType) {
t = (type_params_suiteType) node;
} else {
addAndReportException("type_params_suiteType or exprType", node);
}
}
}
return new TypeAlias(makeNameTok(NameTok.TypeAliasName), t, defaultValue);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ public void testTypeSyntax() {
parseLegalDocStr(s);
}

public void testTypeSyntax2() {
String s = """
type IntOrStr = int | str
""";
parseLegalDocStr(s);
}

public void testTypeNameStillValidSyntax() {
String s = """
print(type(int))
Expand Down

0 comments on commit 3f7e1f2

Please sign in to comment.