From 49474954cb440175fea291c528c22a4ed3687f6f Mon Sep 17 00:00:00 2001 From: Lucas Mirelmann Date: Thu, 20 Nov 2025 19:46:34 +0100 Subject: [PATCH] Fix grammar for slices Fix the grammar for slices to allow expressions of the form `a[0::2]`. The refactor of the grammar done in ea603026297111a1c8c1ce0c95eb92443d03950d made the unexpected change to disallow this expression. --- spec.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec.md b/spec.md index 7707b3e..7d16b6b 100644 --- a/spec.md +++ b/spec.md @@ -2642,7 +2642,7 @@ that can be indexed with an integer as above, such as `Sequence`s, `string`, and `bytes`. ```text -SubscriptSuffix = '[' [Expressions] [':' Expression [':' Expression]] ']' . +SubscriptSuffix = '[' [Expressions] ':' [Expression] [':' [Expression]] ']' . ``` A slice expression `a[start:stop:stride]` yields a copy of `a` containing @@ -4781,7 +4781,7 @@ Operand = identifier . DotSuffix = '.' identifier . -SubscriptSuffix = '[' [Expressions] [':' Expression [':' Expression]] ']' +SubscriptSuffix = '[' [Expressions] ':' [Expression] [':' [Expression]] ']' | '[' Expressions ']' . CallSuffix = '(' [Arguments [',']] ')' .