rustpython-ruff_python_parser 0.15.8

Unofficial fork for RustPython
Documentation
---
source: crates/ruff_python_parser/tests/fixtures.rs
input_file: crates/ruff_python_parser/resources/invalid/expressions/dict/named_expression_0.py
---
## AST

```
Module(
    ModModule {
        node_index: NodeIndex(None),
        range: 0..84,
        body: [
            Expr(
                StmtExpr {
                    node_index: NodeIndex(None),
                    range: 55..77,
                    value: Dict(
                        ExprDict {
                            node_index: NodeIndex(None),
                            range: 55..77,
                            items: [
                                DictItem {
                                    key: Some(
                                        Named(
                                            ExprNamed {
                                                node_index: NodeIndex(None),
                                                range: 56..62,
                                                target: Name(
                                                    ExprName {
                                                        node_index: NodeIndex(None),
                                                        range: 56..57,
                                                        id: Name("x"),
                                                        ctx: Store,
                                                    },
                                                ),
                                                value: NumberLiteral(
                                                    ExprNumberLiteral {
                                                        node_index: NodeIndex(None),
                                                        range: 61..62,
                                                        value: Int(
                                                            1,
                                                        ),
                                                    },
                                                ),
                                            },
                                        ),
                                    ),
                                    value: Name(
                                        ExprName {
                                            node_index: NodeIndex(None),
                                            range: 64..65,
                                            id: Name("y"),
                                            ctx: Load,
                                        },
                                    ),
                                },
                                DictItem {
                                    key: Some(
                                        Name(
                                            ExprName {
                                                node_index: NodeIndex(None),
                                                range: 67..68,
                                                id: Name("z"),
                                                ctx: Load,
                                            },
                                        ),
                                    ),
                                    value: Name(
                                        ExprName {
                                            node_index: NodeIndex(None),
                                            range: 68..68,
                                            id: Name(""),
                                            ctx: Invalid,
                                        },
                                    ),
                                },
                                DictItem {
                                    key: Some(
                                        NumberLiteral(
                                            ExprNumberLiteral {
                                                node_index: NodeIndex(None),
                                                range: 72..73,
                                                value: Int(
                                                    2,
                                                ),
                                            },
                                        ),
                                    ),
                                    value: Name(
                                        ExprName {
                                            node_index: NodeIndex(None),
                                            range: 75..76,
                                            id: Name("a"),
                                            ctx: Load,
                                        },
                                    ),
                                },
                            ],
                        },
                    ),
                },
            ),
            Expr(
                StmtExpr {
                    node_index: NodeIndex(None),
                    range: 79..84,
                    value: BinOp(
                        ExprBinOp {
                            node_index: NodeIndex(None),
                            range: 79..84,
                            left: Name(
                                ExprName {
                                    node_index: NodeIndex(None),
                                    range: 79..80,
                                    id: Name("x"),
                                    ctx: Load,
                                },
                            ),
                            op: Add,
                            right: Name(
                                ExprName {
                                    node_index: NodeIndex(None),
                                    range: 83..84,
                                    id: Name("y"),
                                    ctx: Load,
                                },
                            ),
                        },
                    ),
                },
            ),
        ],
    },
)
```
## Errors

  |
1 | # Unparenthesized named expression not allowed in key
2 |
3 | {x := 1: y, z := 2: a}
  |  ^^^^^^ Syntax Error: Unparenthesized named expression cannot be used here
4 |
5 | x + y
  |


  |
1 | # Unparenthesized named expression not allowed in key
2 |
3 | {x := 1: y, z := 2: a}
  |               ^^ Syntax Error: Expected `:`, found `:=`
4 |
5 | x + y
  |