mirror of
https://github.com/python/cpython.git
synced 2025-12-10 02:50:09 +00:00
bpo-40334: Produce better error messages on invalid targets (GH-20106)
The following error messages get produced: - `cannot delete ...` for invalid `del` targets - `... is an illegal 'for' target` for invalid targets in for statements - `... is an illegal 'with' target` for invalid targets in with statements Additionally, a few `cut`s were added in various places before the invocation of the `invalid_*` rule, in order to speed things up. Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
This commit is contained in:
parent
d906f0ec1a
commit
01ece63d42
6 changed files with 2651 additions and 2256 deletions
|
|
@ -263,11 +263,21 @@ int _PyPegen_check_barry_as_flufl(Parser *);
|
|||
mod_ty _PyPegen_make_module(Parser *, asdl_seq *);
|
||||
|
||||
// Error reporting helpers
|
||||
expr_ty _PyPegen_get_invalid_target(expr_ty e);
|
||||
typedef enum {
|
||||
STAR_TARGETS,
|
||||
DEL_TARGETS,
|
||||
FOR_TARGETS
|
||||
} TARGETS_TYPE;
|
||||
expr_ty _PyPegen_get_invalid_target(expr_ty e, TARGETS_TYPE targets_type);
|
||||
#define GET_INVALID_TARGET(e) (expr_ty)CHECK(_PyPegen_get_invalid_target(e, STAR_TARGETS))
|
||||
#define GET_INVALID_DEL_TARGET(e) (expr_ty)CHECK_NULL_ALLOWED(_PyPegen_get_invalid_target(e, DEL_TARGETS))
|
||||
#define GET_INVALID_FOR_TARGET(e) (expr_ty)CHECK_NULL_ALLOWED(_PyPegen_get_invalid_target(e, FOR_TARGETS))
|
||||
|
||||
void *_PyPegen_arguments_parsing_error(Parser *, expr_ty);
|
||||
void *_PyPegen_nonparen_genexp_in_call(Parser *p, expr_ty args);
|
||||
|
||||
|
||||
// Generated function in parse.c - function definition in python.gram
|
||||
void *_PyPegen_parse(Parser *);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue