aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLysandros Nikolaou <lisandrosnik@gmail.com>2021-01-08 00:31:25 +0200
committerGitHub <noreply@github.com>2021-01-07 14:31:25 -0800
commit07dcd86ceed0bd88d1e96dcf53b1de2fea024385 (patch)
tree4bcfb1f5fd933133abc964d8317e835a2bc7cb5b /Grammar
parentbpo-42851: [Enum] remove brittle __init_subclass__ support (GH-24154) (diff)
downloadcpython-07dcd86ceed0bd88d1e96dcf53b1de2fea024385.tar.gz
cpython-07dcd86ceed0bd88d1e96dcf53b1de2fea024385.tar.bz2
cpython-07dcd86ceed0bd88d1e96dcf53b1de2fea024385.zip
bpo-42860: Remove type error from grammar (GH-24156)
This is only there so that alternative implementations written in statically-typed languages can use this grammar without having type errors in the way. Automerge-Triggered-By: GH:lysnikolaou
Diffstat (limited to 'Grammar')
-rw-r--r--Grammar/python.gram10
1 files changed, 8 insertions, 2 deletions
diff --git a/Grammar/python.gram b/Grammar/python.gram
index 8517bf2f9ba..05ddce520fb 100644
--- a/Grammar/python.gram
+++ b/Grammar/python.gram
@@ -696,11 +696,17 @@ invalid_dict_comprehension:
| '{' a='**' bitwise_or for_if_clauses '}' {
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "dict unpacking cannot be used in dict comprehension") }
invalid_parameters:
- | param_no_default* (slash_with_default | param_with_default+) param_no_default {
+ | param_no_default* invalid_parameters_helper param_no_default {
RAISE_SYNTAX_ERROR("non-default argument follows default argument") }
+invalid_parameters_helper: # This is only there to avoid type errors
+ | a=slash_with_default { _PyPegen_singleton_seq(p, a) }
+ | param_with_default+
invalid_lambda_parameters:
- | lambda_param_no_default* (lambda_slash_with_default | lambda_param_with_default+) lambda_param_no_default {
+ | lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default {
RAISE_SYNTAX_ERROR("non-default argument follows default argument") }
+invalid_lambda_parameters_helper:
+ | a=lambda_slash_with_default { _PyPegen_singleton_seq(p, a) }
+ | lambda_param_with_default+
invalid_star_etc:
| '*' (')' | ',' (')' | '**')) { RAISE_SYNTAX_ERROR("named arguments must follow bare *") }
| '*' ',' TYPE_COMMENT { RAISE_SYNTAX_ERROR("bare * has associated type comment") }