| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -249,7 +249,7 @@ class_def[stmt_ty]: | |||
| 249 | 249 | ||
| 250 | 250 | class_def_raw[stmt_ty]: | |
| 251 | 251 | | invalid_class_def_raw | |
| 252 | - | 'class' a=NAME b=['(' z=[arguments] ')' { z }] &&':' c=block { | ||
| 252 | + | 'class' a=NAME b=['(' z=[arguments] ')' { z }] ':' c=block { | ||
| 253 | 253 | _PyAST_ClassDef(a->v.Name.id, | |
| 254 | 254 | (b) ? ((expr_ty) b)->v.Call.args : NULL, | |
| 255 | 255 | (b) ? ((expr_ty) b)->v.Call.keywords : NULL, | |
@@ -379,9 +379,9 @@ while_stmt[stmt_ty]: | |||
| 379 | 379 | ||
| 380 | 380 | for_stmt[stmt_ty]: | |
| 381 | 381 | | invalid_for_stmt | |
| 382 | - | 'for' t=star_targets 'in' ~ ex=star_expressions &&':' tc=[TYPE_COMMENT] b=block el=[else_block] { | ||
| 382 | + | 'for' t=star_targets 'in' ~ ex=star_expressions ':' tc=[TYPE_COMMENT] b=block el=[else_block] { | ||
| 383 | 383 | _PyAST_For(t, ex, b, el, NEW_TYPE_COMMENT(p, tc), EXTRA) } | |
| 384 | - | ASYNC 'for' t=star_targets 'in' ~ ex=star_expressions &&':' tc=[TYPE_COMMENT] b=block el=[else_block] { | ||
| 384 | + | ASYNC 'for' t=star_targets 'in' ~ ex=star_expressions ':' tc=[TYPE_COMMENT] b=block el=[else_block] { | ||
| 385 | 385 | CHECK_VERSION(stmt_ty, 5, "Async for loops are", _PyAST_AsyncFor(t, ex, b, el, NEW_TYPE_COMMENT(p, tc), EXTRA)) } | |
| 386 | 386 | | invalid_for_target | |
| 387 | 387 | ||
@@ -1231,8 +1231,8 @@ invalid_import_from_targets: | |||
| 1231 | 1231 | RAISE_SYNTAX_ERROR("trailing comma not allowed without surrounding parentheses") } | |
| 1232 | 1232 | ||
| 1233 | 1233 | invalid_with_stmt: | |
| 1234 | - | [ASYNC] 'with' ','.(expression ['as' star_target])+ &&':' | ||
| 1235 | - | [ASYNC] 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' &&':' | ||
| 1234 | + | [ASYNC] 'with' ','.(expression ['as' star_target])+ NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") } | ||
| 1235 | + | [ASYNC] 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") } | ||
| 1236 | 1236 | invalid_with_stmt_indent: | |
| 1237 | 1237 | | [ASYNC] a='with' ','.(expression ['as' star_target])+ ':' NEWLINE !INDENT { | |
| 1238 | 1238 | RAISE_INDENTATION_ERROR("expected an indented block after 'with' statement on line %d", a->lineno) } | |
@@ -1262,11 +1262,11 @@ invalid_except_star_stmt_indent: | |||
| 1262 | 1262 | | a='except' '*' expression ['as' NAME ] ':' NEWLINE !INDENT { | |
| 1263 | 1263 | RAISE_INDENTATION_ERROR("expected an indented block after 'except*' statement on line %d", a->lineno) } | |
| 1264 | 1264 | invalid_match_stmt: | |
| 1265 | - | "match" subject_expr !':' { CHECK_VERSION(void*, 10, "Pattern matching is", RAISE_SYNTAX_ERROR("expected ':'") ) } | ||
| 1265 | + | "match" subject_expr NEWLINE { CHECK_VERSION(void*, 10, "Pattern matching is", RAISE_SYNTAX_ERROR("expected ':'") ) } | ||
| 1266 | 1266 | | a="match" subject=subject_expr ':' NEWLINE !INDENT { | |
| 1267 | 1267 | RAISE_INDENTATION_ERROR("expected an indented block after 'match' statement on line %d", a->lineno) } | |
| 1268 | 1268 | invalid_case_block: | |
| 1269 | - | "case" patterns guard? !':' { RAISE_SYNTAX_ERROR("expected ':'") } | ||
| 1269 | + | "case" patterns guard? NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") } | ||
| 1270 | 1270 | | a="case" patterns guard? ':' NEWLINE !INDENT { | |
| 1271 | 1271 | RAISE_INDENTATION_ERROR("expected an indented block after 'case' statement on line %d", a->lineno) } | |
| 1272 | 1272 | invalid_as_pattern: | |
@@ -1295,13 +1295,15 @@ invalid_while_stmt: | |||
| 1295 | 1295 | | a='while' named_expression ':' NEWLINE !INDENT { | |
| 1296 | 1296 | RAISE_INDENTATION_ERROR("expected an indented block after 'while' statement on line %d", a->lineno) } | |
| 1297 | 1297 | invalid_for_stmt: | |
| 1298 | + | [ASYNC] 'for' star_targets 'in' star_expressions NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") } | ||
| 1298 | 1299 | | [ASYNC] a='for' star_targets 'in' star_expressions ':' NEWLINE !INDENT { | |
| 1299 | 1300 | RAISE_INDENTATION_ERROR("expected an indented block after 'for' statement on line %d", a->lineno) } | |
| 1300 | 1301 | invalid_def_raw: | |
| 1301 | 1302 | | [ASYNC] a='def' NAME '(' [params] ')' ['->' expression] ':' NEWLINE !INDENT { | |
| 1302 | 1303 | RAISE_INDENTATION_ERROR("expected an indented block after function definition on line %d", a->lineno) } | |
| 1303 | 1304 | invalid_class_def_raw: | |
| 1304 | - | a='class' NAME ['('[arguments] ')'] ':' NEWLINE !INDENT { | ||
| 1305 | + | 'class' NAME ['(' [arguments] ')'] NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") } | ||
| 1306 | + | a='class' NAME ['(' [arguments] ')'] ':' NEWLINE !INDENT { | ||
| 1305 | 1307 | RAISE_INDENTATION_ERROR("expected an indented block after class definition on line %d", a->lineno) } | |
| 1306 | 1308 | ||
| 1307 | 1309 | invalid_double_starred_kvpairs: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -607,7 +607,7 @@ | |||
| 607 | 607 | >>> class C(x for x in L): | |
| 608 | 608 | ... pass | |
| 609 | 609 | Traceback (most recent call last): | |
| 610 | - SyntaxError: expected ':' | ||
| 610 | + SyntaxError: invalid syntax | ||
| 611 | 611 | ||
| 612 | 612 | >>> def g(*args, **kwargs): | |
| 613 | 613 | ... print(args, sorted(kwargs.items())) | |
@@ -963,17 +963,22 @@ | |||
| 963 | 963 | ... | |
| 964 | 964 | SyntaxError: cannot assign to function call here. Maybe you meant '==' instead of '='? | |
| 965 | 965 | ||
| 966 | - Missing ':' before suites: | ||
| 966 | + Missing ':' before suites: | ||
| 967 | 967 | ||
| 968 | - >>> def f() | ||
| 969 | - ... pass | ||
| 970 | - Traceback (most recent call last): | ||
| 971 | - SyntaxError: expected ':' | ||
| 968 | + >>> def f() | ||
| 969 | + ... pass | ||
| 970 | + Traceback (most recent call last): | ||
| 971 | + SyntaxError: expected ':' | ||
| 972 | 972 | ||
| 973 | - >>> class A | ||
| 974 | - ... pass | ||
| 975 | - Traceback (most recent call last): | ||
| 976 | - SyntaxError: expected ':' | ||
| 973 | + >>> class A | ||
| 974 | + ... pass | ||
| 975 | + Traceback (most recent call last): | ||
| 976 | + SyntaxError: expected ':' | ||
| 977 | + | ||
| 978 | + >>> class R&D: | ||
| 979 | + ... pass | ||
| 980 | + Traceback (most recent call last): | ||
| 981 | + SyntaxError: invalid syntax | ||
| 977 | 982 | ||
| 978 | 983 | >>> if 1 | |
| 979 | 984 | ... pass | |
@@ -1007,6 +1012,11 @@ | |||
| 1007 | 1012 | Traceback (most recent call last): | |
| 1008 | 1013 | SyntaxError: expected ':' | |
| 1009 | 1014 | ||
| 1015 | + >>> for x in range 10: | ||
| 1016 | + ... pass | ||
| 1017 | + Traceback (most recent call last): | ||
| 1018 | + SyntaxError: invalid syntax | ||
| 1019 | + | ||
| 1010 | 1020 | >>> while True | |
| 1011 | 1021 | ... pass | |
| 1012 | 1022 | Traceback (most recent call last): | |
@@ -1052,6 +1062,11 @@ | |||
| 1052 | 1062 | Traceback (most recent call last): | |
| 1053 | 1063 | SyntaxError: expected ':' | |
| 1054 | 1064 | ||
| 1065 | + >>> with block ad something: | ||
| 1066 | + ... pass | ||
| 1067 | + Traceback (most recent call last): | ||
| 1068 | + SyntaxError: invalid syntax | ||
| 1069 | + | ||
| 1055 | 1070 | >>> try | |
| 1056 | 1071 | ... pass | |
| 1057 | 1072 | Traceback (most recent call last): | |
@@ -1070,6 +1085,12 @@ | |||
| 1070 | 1085 | Traceback (most recent call last): | |
| 1071 | 1086 | SyntaxError: expected ':' | |
| 1072 | 1087 | ||
| 1088 | + >>> match x x: | ||
| 1089 | + ... case list(): | ||
| 1090 | + ... pass | ||
| 1091 | + Traceback (most recent call last): | ||
| 1092 | + SyntaxError: invalid syntax | ||
| 1093 | + | ||
| 1073 | 1094 | >>> match x: | |
| 1074 | 1095 | ... case list() | |
| 1075 | 1096 | ... pass | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + Improve error message for some suites with syntax error before ':' | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments