| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8bee2a3 commit 1034e73
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -835,7 +835,6 @@ bitwise_and[expr_ty]: | |||
| 835 | 835 | shift_expr[expr_ty]: | |
| 836 | 836 | | a=shift_expr '<<' b=sum { _PyAST_BinOp(a, LShift, b, EXTRA) } | |
| 837 | 837 | | a=shift_expr '>>' b=sum { _PyAST_BinOp(a, RShift, b, EXTRA) } | |
| 838 | - | invalid_arithmetic | ||
| 839 | 838 | | sum | |
| 840 | 839 | ||
| 841 | 840 | # Arithmetic operators | |
@@ -844,6 +843,7 @@ shift_expr[expr_ty]: | |||
| 844 | 843 | sum[expr_ty]: | |
| 845 | 844 | | a=sum '+' b=term { _PyAST_BinOp(a, Add, b, EXTRA) } | |
| 846 | 845 | | a=sum '-' b=term { _PyAST_BinOp(a, Sub, b, EXTRA) } | |
| 846 | + | invalid_arithmetic | ||
| 847 | 847 | | term | |
| 848 | 848 | ||
| 849 | 849 | term[expr_ty]: | |
@@ -852,14 +852,14 @@ term[expr_ty]: | |||
| 852 | 852 | | a=term '//' b=factor { _PyAST_BinOp(a, FloorDiv, b, EXTRA) } | |
| 853 | 853 | | a=term '%' b=factor { _PyAST_BinOp(a, Mod, b, EXTRA) } | |
| 854 | 854 | | a=term '@' b=factor { CHECK_VERSION(expr_ty, 5, "The '@' operator is", _PyAST_BinOp(a, MatMult, b, EXTRA)) } | |
| 855 | - | invalid_factor | ||
| 856 | 855 | | factor | |
| 857 | 856 | ||
| 858 | 857 | factor[expr_ty] (memo): | |
| 859 | 858 | | '+' a=factor { _PyAST_UnaryOp(UAdd, a, EXTRA) } | |
| 860 | 859 | | '-' a=factor { _PyAST_UnaryOp(USub, a, EXTRA) } | |
| 861 | 860 | | '~' a=factor { _PyAST_UnaryOp(Invert, a, EXTRA) } | |
| 862 | 861 | | power | |
| 862 | + | invalid_factor | ||
| 863 | 863 | ||
| 864 | 864 | power[expr_ty]: | |
| 865 | 865 | | a=await_primary '**' b=factor { _PyAST_BinOp(a, Pow, b, EXTRA) } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2268,6 +2268,22 @@ | |||
| 2268 | 2268 | Traceback (most recent call last): | |
| 2269 | 2269 | SyntaxError: 'not' after an operator must be parenthesized | |
| 2270 | 2270 | ||
| 2271 | + >>> 1 << 2 + not 3 | ||
| 2272 | + Traceback (most recent call last): | ||
| 2273 | + SyntaxError: 'not' after an operator must be parenthesized | ||
| 2274 | + | ||
| 2275 | + >>> 1 >> 2 * not 3 | ||
| 2276 | + Traceback (most recent call last): | ||
| 2277 | + SyntaxError: 'not' after an operator must be parenthesized | ||
| 2278 | + | ||
| 2279 | + >>> 3 * + not 3 | ||
| 2280 | + Traceback (most recent call last): | ||
| 2281 | + SyntaxError: 'not' after an operator must be parenthesized | ||
| 2282 | + | ||
| 2283 | + >>> 3 ** - not 3 | ||
| 2284 | + Traceback (most recent call last): | ||
| 2285 | + SyntaxError: 'not' after an operator must be parenthesized | ||
| 2286 | + | ||
| 2271 | 2287 | # Check that we don't introduce misleading errors | |
| 2272 | 2288 | >>> not 1 */ 2 | |
| 2273 | 2289 | Traceback (most recent call last): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + Improve syntax error messages for misplaced ``not`` after an operator | ||
| 2 | + in contexts where a generic "invalid syntax" error was previously reported, | ||
| 3 | + such as ``1 << 2 + not x`` and ``1 * + not x``. | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments