Skip to content

Commit 29308e7

Browse files
authored
Accept positional-only arguments syntax (#2001)
1 parent 52c9436 commit 29308e7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/core/IronPython/Compiler/Parser.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1201,6 +1201,7 @@ private Parameter[] ParseParameterList(TokenKind terminator, bool allowAnnotatio
12011201
HashSet<string> names = new HashSet<string>(StringComparer.Ordinal);
12021202
bool needDefault = false;
12031203
bool readMultiply = false;
1204+
bool readTrueDivide = false;
12041205
bool hasKeywordOnlyParameter = false;
12051206
// we want these to be the last two parameters
12061207
Parameter listParameter = null;
@@ -1221,7 +1222,14 @@ private Parameter[] ParseParameterList(TokenKind terminator, bool allowAnnotatio
12211222
break;
12221223
}
12231224

1224-
if (MaybeEat(TokenKind.Multiply)) {
1225+
if (MaybeEat(TokenKind.TrueDivide)) { // accept syntax for positional-only parameters from Python 3.8
1226+
if (position == 0 || readMultiply || readTrueDivide) {
1227+
ReportSyntaxError(_lookahead);
1228+
return null;
1229+
}
1230+
1231+
readTrueDivide = true;
1232+
} else if (MaybeEat(TokenKind.Multiply)) {
12251233
if (readMultiply) {
12261234
ReportSyntaxError(_lookahead);
12271235
return null;

0 commit comments

Comments
 (0)