---
source: crates/ruff_python_parser/tests/fixtures.rs
input_file: crates/ruff_python_parser/resources/invalid/expressions/named/invalid_target.py
---
## AST

```
Module(
    ModModule {
        range: 0..109,
        body: [
            Expr(
                StmtExpr {
                    range: 58..68,
                    value: Named(
                        ExprNamed {
                            range: 59..67,
                            target: Attribute(
                                ExprAttribute {
                                    range: 59..62,
                                    value: Name(
                                        ExprName {
                                            range: 59..60,
                                            id: "x",
                                            ctx: Load,
                                        },
                                    ),
                                    attr: Identifier {
                                        id: "y",
                                        range: 61..62,
                                    },
                                    ctx: Store,
                                },
                            ),
                            value: NumberLiteral(
                                ExprNumberLiteral {
                                    range: 66..67,
                                    value: Int(
                                        1,
                                    ),
                                },
                            ),
                        },
                    ),
                },
            ),
            Expr(
                StmtExpr {
                    range: 69..80,
                    value: Named(
                        ExprNamed {
                            range: 70..79,
                            target: Subscript(
                                ExprSubscript {
                                    range: 70..74,
                                    value: Name(
                                        ExprName {
                                            range: 70..71,
                                            id: "x",
                                            ctx: Load,
                                        },
                                    ),
                                    slice: Name(
                                        ExprName {
                                            range: 72..73,
                                            id: "y",
                                            ctx: Load,
                                        },
                                    ),
                                    ctx: Store,
                                },
                            ),
                            value: NumberLiteral(
                                ExprNumberLiteral {
                                    range: 78..79,
                                    value: Int(
                                        1,
                                    ),
                                },
                            ),
                        },
                    ),
                },
            ),
            Expr(
                StmtExpr {
                    range: 81..84,
                    value: Starred(
                        ExprStarred {
                            range: 82..84,
                            value: Name(
                                ExprName {
                                    range: 83..84,
                                    id: "x",
                                    ctx: Load,
                                },
                            ),
                            ctx: Load,
                        },
                    ),
                },
            ),
            Expr(
                StmtExpr {
                    range: 88..89,
                    value: NumberLiteral(
                        ExprNumberLiteral {
                            range: 88..89,
                            value: Int(
                                1,
                            ),
                        },
                    ),
                },
            ),
            Expr(
                StmtExpr {
                    range: 91..109,
                    value: Named(
                        ExprNamed {
                            range: 92..108,
                            target: List(
                                ExprList {
                                    range: 92..98,
                                    elts: [
                                        Name(
                                            ExprName {
                                                range: 93..94,
                                                id: "x",
                                                ctx: Store,
                                            },
                                        ),
                                        Name(
                                            ExprName {
                                                range: 96..97,
                                                id: "y",
                                                ctx: Store,
                                            },
                                        ),
                                    ],
                                    ctx: Store,
                                },
                            ),
                            value: List(
                                ExprList {
                                    range: 102..108,
                                    elts: [
                                        NumberLiteral(
                                            ExprNumberLiteral {
                                                range: 103..104,
                                                value: Int(
                                                    1,
                                                ),
                                            },
                                        ),
                                        NumberLiteral(
                                            ExprNumberLiteral {
                                                range: 106..107,
                                                value: Int(
                                                    2,
                                                ),
                                            },
                                        ),
                                    ],
                                    ctx: Load,
                                },
                            ),
                        },
                    ),
                },
            ),
        ],
    },
)
```
## Errors

  |
1 | # Assignment expression target can only be an identifier
2 | 
3 | (x.y := 1)
  |  ^^^ Syntax Error: Assignment expression target must be an identifier
4 | (x[y] := 1)
5 | (*x := 1)
  |


  |
3 | (x.y := 1)
4 | (x[y] := 1)
  |  ^^^^ Syntax Error: Assignment expression target must be an identifier
5 | (*x := 1)
6 | ([x, y] := [1, 2])
  |


  |
3 | (x.y := 1)
4 | (x[y] := 1)
5 | (*x := 1)
  |  ^^ Syntax Error: Starred expression cannot be used here
6 | ([x, y] := [1, 2])
  |


  |
3 | (x.y := 1)
4 | (x[y] := 1)
5 | (*x := 1)
  |     ^^ Syntax Error: Expected ')', found ':='
6 | ([x, y] := [1, 2])
  |


  |
3 | (x.y := 1)
4 | (x[y] := 1)
5 | (*x := 1)
  |         ^ Syntax Error: Expected a statement
6 | ([x, y] := [1, 2])
  |


  |
3 | (x.y := 1)
4 | (x[y] := 1)
5 | (*x := 1)
  |          ^ Syntax Error: Expected a statement
6 | ([x, y] := [1, 2])
  |


  |
4 | (x[y] := 1)
5 | (*x := 1)
6 | ([x, y] := [1, 2])
  |  ^^^^^^ Syntax Error: Assignment expression target must be an identifier
  |
